The general principles of twig is either to display data or to display data statements (with functions or tags)

display variable

From the controller, it is possible to send variables, and these variables can be displayed in twig between two braces.

Here an example:

‹p›The price is: {{ price }} $ ‹/p›

if the data is in the form of an associative array, you can indicate the key after a dot. here an example: (like $product["name"] in php)

‹li›Name's product : {{ }} ‹/li›

Use function

There are many twig functions, here is just an example with the if else statement.

To use a function, it must be placed in a brace and a %. Like that:

{% if appUser %}‹p› You are connected ‹/p›
{% else %} ‹p› Please login ‹/p›
{% endif %}

If you have stored data in the session with the user key ($_SESSION["user"]), this data is automatically accessible in the appUser twig variable (feature from voila).

For others functions, just search the official twig documentation.

Twig documentation

The official twig documentation is : Twig doc