The depot board

Exercise 4 of 4 in chapter 1 · 100 XP · 3 objectives checked by tests

Topics covered: ViewTemplaterange

At the depot, an old screen hangs above the bikes. Margot would like to show the list of couriers on it, in big letters, so everyone knows who is riding today.

Your mission

  1. Add a Tableau method (French for “board”) to the controller. It renders the tableau.tmpl view, with two values: titre, set to "The Flying Gophers", and coursiers, the list.
  2. Wire it to GET /board in routes/web.go.
  3. In resources/views/tableau.tmpl, show the title in an <h1> and in the page's <title>, then the list of couriers, one <li> per courier, inside a <ul>. The tests look for exactly <h1>The Flying Gophers</h1> and <li>Margot</li>: no attributes and no spaces inside these tags.

Reminder

Goravel renders its views with the templates from Go's standard library, html/template, where Laravel has Blade. Tags are written between double curly braces: {{ .titre }} prints a value, {{ range .coursiers }} … {{ end }} repeats a block for each item of a list, and {{ if … }} … {{ end }} shows one only under a condition.

Like {{ }} in Blade, html/template escapes what it prints: a first name that contained HTML would be shown as is, without being interpreted.

map[string]any is a map whose keys are strings and whose values can be of any type (any). That's what the view receives.