diff options
Diffstat (limited to 'vendor/twig/twig/doc/filters/batch.rst')
-rw-r--r-- | vendor/twig/twig/doc/filters/batch.rst | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/twig/twig/doc/filters/batch.rst b/vendor/twig/twig/doc/filters/batch.rst new file mode 100644 index 00000000..4366b57b --- /dev/null +++ b/vendor/twig/twig/doc/filters/batch.rst | |||
@@ -0,0 +1,45 @@ | |||
1 | ``batch`` | ||
2 | ========= | ||
3 | |||
4 | .. versionadded:: 1.12.3 | ||
5 | The batch filter was added in Twig 1.12.3. | ||
6 | |||
7 | The ``batch`` filter "batches" items by returning a list of lists with the | ||
8 | given number of items. If you provide a second parameter, it is used to fill | ||
9 | missing 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 | |||
25 | The 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> | ||