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 […]


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 […]