-
-
Save notjb/7155e62cac6b3ceb920b654dc5aa610d to your computer and use it in GitHub Desktop.
Set zebra-style (odd/even) classes in twig loop in drupal 8 (bootstrap) theme
This file contains hidden or 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
| <div{{ attributes.addClass('container') }}> | |
| {% for item in items %} | |
| {% set zebra_class = loop.index0 is odd ? 'zebra-odd' : 'zebra-even' %} | |
| <div{{ item.attributes.addClass(zebra_class) }}> | |
| {{ item.content }} | |
| </div> | |
| {% endfor %} | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment