企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
# `cycle` The `cycle` function cycles on an array of values: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 4 5 6</pre></div></td><td class="code"><div class="highlight"><pre>{% 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 %} </pre></div></td></tr></table> The array can contain any number of values: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 4 5</pre></div></td><td class="code"><div class="highlight"><pre>{% set fruits = ['apple', 'orange', 'citrus'] %} {% for i in 0..10 %} {{ cycle(fruits, i) }} {% endfor %} </pre></div></td></tr></table> ### Arguments - `position`: The cycle position