Created
January 8, 2013 06:29
-
-
Save jpetitcolas/4481722 to your computer and use it in GitHub Desktop.
How to differenciate odd and even rows with Twig?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
{% for record in records %} | |
<tr class="record{% if loop.index is divisibleby(2) %}even{% else %}odd{% endif %}"> | |
<td>{{ record.id }}</td> | |
<td>{{ record.title }}</td> | |
</tr> | |
{% endfor %} | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this works too:
{% if loop.index is even %}
...{% else %}
...{% endif %}