Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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.