``batch``
=========
.. versionadded:: 1.12.3
The batch filter was added in Twig 1.12.3.
The ``batch`` filter "batches" items by returning a list of lists with the
given number of items. If you provide a second parameter, it is used to fill
missing items:
.. code-block:: jinja
{% set items = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] %}
{% for row in items|batch(3, 'No item') %}
{% for column in row %}
| {{ column }} |
{% endfor %}
{% endfor %}
The above example will be rendered as:
.. code-block:: jinja
| a |
b |
c |
| d |
e |
f |
| g |
No item |
No item |