resetcycle Template Tag
Example
Reset the cycle if the fruit is "Banana":
<ul>
{% for x in fruits %}
<li style='color:{% cycle 'red' 'green' 'blue' 'pink' %}'>
{{ x }}
</li>
{% if x == "Banana" %}
{% resetcycle %}
{% endif %}
{% endfor %}
</ul>
Run Example »
Definition and Usage
The resetcycle tag is used inside a
cycle, and resets the cycle, making it start at
the beginning.
It does not reset the loop, only the cycle.
If you have multiple cycles, you can specify which one to reset with the name argument:
Example
Reset the mybg cycle if the fruit is
"Banana":
<ul>
{% for x in fruits %}
<li style='
color:{% cycle 'red' 'green' 'blue' 'pink' as mycolor %};
background:{% cycle 'grey' 'beige' 'coral' 'brown' as mybg %};
'>{{ x }}</li>
{% if x == "Banana" %}
{% resetcycle mybg %}
{% endif %}
{% endfor %}
</ul>
Run Example »
Syntax
{% resetcycle name %}
Parameters
| Value | Description |
|---|---|
| name | Optional. The name of the cycle to reset. |