Ticket #5865: cycle-doc.diff

File cycle-doc.diff, 1.2 KB (added by munhitsu, 8 years ago)
  • docs/templates.txt

     
    591591~~~~~
    592592
    593593**Changed in Django development version**
    594 Cycle among the given strings or variables each time this tag is encountered.
     594Cycle among the given strings, variables, iterable type each time this tag is encountered.
    595595
    596596Within a loop, cycles among the given strings/variables each time through the
    597597loop::
     
    621621comma-based syntax exists for backwards-compatibility, and should not be
    622622used for new projects.
    623623
     624In case you pass a single value which is an iterable variable defined in the context cycle iterates over its values.
     625Example context definition::
     626
     627        {'colors': ['red', 'blue', 'green']}
     628
     629Example usage::
     630
     631        {% for row in mydata %}
     632        <tr class="{% cycle colors %}">...</tr>
     633        {% endfor %}
     634
     635        {% for row in mydata %}
     636        <tr class="{% cycle colors as color%}">...</tr>
     637        {% endfor %}
     638
     639        <tr class="{% cycle colors as color %}">...</tr>
     640        <tr class="{% cycle color %}">...</tr>
     641        <tr class="{% cycle color %}">...</tr>
     642
     643
    624644debug
    625645~~~~~
    626646
Back to Top