Created
June 14, 2018 05:12
-
-
Save ben-rogerson/1560ab98f5e523b0c448d62f0128c0e2 to your computer and use it in GitHub Desktop.
Equal columns in 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
{% set items = [...] %} | |
{% set itemsPerColumn = (items|length / 2)|round %} | |
{% for column in items|batch(itemsPerColumn) %} | |
<div class="column"> | |
{% for item in column %} | |
<div class="item"> | |
{{ item }} | |
</div> | |
{% endfor %} | |
</div> | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment