Code

Ticket #5865: cycle-doc.diff

File cycle-doc.diff, 1.2 KB (added by munhitsu, 6 years ago)
Line 
1Index: docs/templates.txt
2===================================================================
3--- docs/templates.txt  (revision 6799)
4+++ docs/templates.txt  (working copy)
5@@ -591,7 +591,7 @@
6 ~~~~~
7 
8 **Changed in Django development version**
9-Cycle among the given strings or variables each time this tag is encountered.
10+Cycle among the given strings, variables, iterable type each time this tag is encountered.
11 
12 Within a loop, cycles among the given strings/variables each time through the
13 loop::
14@@ -621,6 +621,26 @@
15 comma-based syntax exists for backwards-compatibility, and should not be
16 used for new projects.
17 
18+In case you pass a single value which is an iterable variable defined in the context cycle iterates over its values.
19+Example context definition::
20+
21+        {'colors': ['red', 'blue', 'green']}
22+
23+Example usage::
24+
25+        {% for row in mydata %}
26+        <tr class="{% cycle colors %}">...</tr>
27+        {% endfor %}
28+
29+        {% for row in mydata %}
30+        <tr class="{% cycle colors as color%}">...</tr>
31+        {% endfor %}
32+
33+        <tr class="{% cycle colors as color %}">...</tr>
34+        <tr class="{% cycle color %}">...</tr>
35+        <tr class="{% cycle color %}">...</tr>
36+
37+
38 debug
39 ~~~~~
40