twig comparison code example
Example 1: modele de twig html : payant
<?php
include 'vendor/autoload.php';
try {
$loader = new Twig\Loader\FilesystemLoader('templates');
$twig = new Twig\Environment($loader);
$template = $twig->load('Menu.html');
echo $template->render(array(
'lundi' => 'Steak Frites',
'mardi' => 'Raviolis',
'mercredi' => 'Pot au Feu',
'jeudi' => 'Couscous',
'vendredi' => 'Poisson',
));
} catch (Exception $e) {
die ('ERROR: ' . $e->getMessage());
}
Example 2: modele de twig html : payant
<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>
<h1>My Webpage</h1>
{{ a_variable }}
</body>
</html>