Home »
Documentation »
Filters »
split_in
Split a list in shorter lists.
Splits an array in N sub-arrays of more or less equal length. This is useful when displaying a list of items in columns.
For example:
{% for a,b,c in [1,2,3,4,5,6]|split_in:3 %}
{% for n in a %}{{ n|format_number }} {% endfor %}
{% endfor %}This displays “1 4”. The variable b will be [2,5] and the variable c will be [3,6].
See also the filters vsplit_in and chunk.
This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.