Top menu

Advanced example of using the “for” and “loop” in twig

This example illustrate how to use a nested “for” in twig also the use of a loop instruction:

Inside of a for loop block you can access some special variables: Variable Description loop.index The current iteration of the loop. (1 indexed) loop.index0 The current iteration of the loop. (0 indexed) loop.revindex The number of iterations from […]


How to use the Intl Extension Twig for date

First you should install the php5-intl :

Then add the code below in your “app/config/config.yml” file :

Finaly in you twig file you can use the localizeddate filter to format dates into a localized string representating the date :



Enable the debug extension in Twig

To enable the debug function in twig. You have to modify the file app/config_dev.yml by adding the code below :

Then in your twig file (ex : test.html.twig) : {% debug %} => Display all variables assigned to the template engine for the view in question {% debug var %} => Displays information about […]