cycle
¶
这个 cycle
值数组上的函数循环:
1 2 3 4 5 6 | {% set start_year = date() | date('Y') %}
{% set end_year = start_year + 5 %}
{% for year in start_year..end_year %}
{{ cycle(['odd', 'even'], loop.index0) }}
{% endfor %}
|
数组可以包含任意数量的值:
1 2 3 4 5 | {% set fruits = ['apple', 'orange', 'citrus'] %}
{% for i in 0..10 %}
{{ cycle(fruits, i) }}
{% endfor %}
|
争论¶
position
:循环位置