pico/lib/twig/doc/functions/cycle.rst
Gilbert Pellegrom 92b792e8f2 Initial commit.
2012-04-04 14:45:09 +01:00

21 lines
376 B
ReStructuredText
Executable File

``cycle``
=========
The ``cycle`` function cycles on an array of values:
.. code-block:: jinja
{% for i in 0..10 %}
{{ cycle(['odd', 'even'], i) }}
{% endfor %}
The array can contain any number of values:
.. code-block:: jinja
{% set fruits = ['apple', 'orange', 'citrus'] %}
{% for i in 0..10 %}
{{ cycle(fruits, i) }}
{% endfor %}