Twig and Symfony2 - test if a number is even
if-statement, symfony, twig
Solution
Twig has a built in "even" test:
{% if (loop.index is even) %}
...your code here
{% endif %}
Problem
I would like to create a table with different color for each even row. For that, I created the css and I will have to check in my twig template if the iteration index is even or not. ``` {% if loop.index == "even" %} ``` But how to check if a number is even in twig? Thank you.