]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
1 | ``cycle`` |
2 | ========= | |
3 | ||
4 | The ``cycle`` function cycles on an array of values: | |
5 | ||
6 | .. code-block:: jinja | |
7 | ||
8 | {% for i in 0..10 %} | |
9 | {{ cycle(['odd', 'even'], i) }} | |
10 | {% endfor %} | |
11 | ||
12 | The array can contain any number of values: | |
13 | ||
14 | .. code-block:: jinja | |
15 | ||
16 | {% set fruits = ['apple', 'orange', 'citrus'] %} | |
17 | ||
18 | {% for i in 0..10 %} | |
19 | {{ cycle(fruits, i) }} | |
20 | {% endfor %} | |
21 | ||
22 | Arguments | |
23 | --------- | |
24 | ||
25 | * ``position``: The cycle position |