cycle.rst 376B

123456789101112131415161718192021
  1. ``cycle``
  2. =========
  3. The ``cycle`` function cycles on an array of values:
  4. .. code-block:: jinja
  5. {% for i in 0..10 %}
  6. {{ cycle(['odd', 'even'], i) }}
  7. {% endfor %}
  8. The array can contain any number of values:
  9. .. code-block:: jinja
  10. {% set fruits = ['apple', 'orange', 'citrus'] %}
  11. {% for i in 0..10 %}
  12. {{ cycle(fruits, i) }}
  13. {% endfor %}