1``batch`` 2========= 3 4.. versionadded:: 1.12.3 5 The ``batch`` filter was added in Twig 1.12.3. 6 7The ``batch`` filter "batches" items by returning a list of lists with the 8given number of items. A second parameter can be provided and used to fill in 9missing items: 10 11.. code-block:: jinja 12 13 {% set items = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] %} 14 15 <table> 16 {% for row in items|batch(3, 'No item') %} 17 <tr> 18 {% for column in row %} 19 <td>{{ column }}</td> 20 {% endfor %} 21 </tr> 22 {% endfor %} 23 </table> 24 25The above example will be rendered as: 26 27.. code-block:: jinja 28 29 <table> 30 <tr> 31 <td>a</td> 32 <td>b</td> 33 <td>c</td> 34 </tr> 35 <tr> 36 <td>d</td> 37 <td>e</td> 38 <td>f</td> 39 </tr> 40 <tr> 41 <td>g</td> 42 <td>No item</td> 43 <td>No item</td> 44 </tr> 45 </table> 46 47Arguments 48--------- 49 50* ``size``: The size of the batch; fractional numbers will be rounded up 51* ``fill``: Used to fill in missing items 52