1<ul>
2 {% for key, user in users %}
3 <li>{{ key }}: {{ user.username|e }}</li>
4 {% endfor %}
5</ul>
1{% for user in users %}
2 {{ loop.index }} - {{ user.username }}
3{% endfor %}
4
1<?php
2// menu.php
3// inclure l'autoloader
4include 'vendor/autoload.php';
5
6try {
7 // le dossier ou on trouve les templates
8 $loader = new Twig\Loader\FilesystemLoader('templates');
9
10 // initialiser l'environement Twig
11 $twig = new Twig\Environment($loader);
12
13 // load template
14 $template = $twig->load('Menu.html');
15
16 // set template variables
17 // render template
18 echo $template->render(array(
19 'lundi' => 'Steak Frites',
20 'mardi' => 'Raviolis',
21 'mercredi' => 'Pot au Feu',
22 'jeudi' => 'Couscous',
23 'vendredi' => 'Poisson',
24 ));
25
26} catch (Exception $e) {
27 die ('ERROR: ' . $e->getMessage());
28}
29