Prices in gold pieces

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

Topics covered: Twig loopFiltersConditions

A goblin accountant has complained: the menu doesn't show the prices. Outrageous. Gorm asks you to redo the menu in Twig, and to show off his specialties while you're at it.

The controller now passes the whole plats array to the template, indexed by slug: each dish has a nom (name), a prix (price) and a specialite (specialty) boolean.

Your mission

In templates/menu/index.html.twig, for each dish in the <ul class="plats"> list:

  1. a link to its page (route app_plat), with the dish name as its text;
  2. its price formatted as 12.50 gp (two decimals, decimal point);
  3. a <span class="specialite">Specialty</span> badge, only for specialties.

And if one day the menu is empty (mushroom shortage…), display “The kitchen is closed.”.

Reminder

Twig filters values with |: {{ value|filter(arguments) }}. path() generates the URL of a named route, parameters included.