Templates
Twig Templating Language
The Twig templating language allows you to write concise, readable templates that are more friendly to web designers and, in several ways, more powerful than PHP templates. Take a look at the following Twig template example. Even if it's the first time you see Twig, you probably understand most of it:
You can't run PHP code inside Twig templates, but Twig provides utilities to run some logic in the templates. For example, filters modify content before being rendered, like the upper
filter to uppercase contents:
Creating Templates
Before explaining in detail how to create and render templates, look at the following example for a quick overview of the whole process. First, you need to create a new file in the templates/
directory to store the template contents:
Then, create a controller that renders this template and passes to it the needed variables:
Last updated
Was this helpful?