summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-11-02 13:42:30 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-11-02 13:42:30 +0000
commita89e02637b04b95f50087d53289e8aca8cd58007 (patch)
treed06df0f5ba4a0fd1f8fa61abc955c8dcb6514fc4 /docs/ref
parentbb062c376ff561497f3ddef77fe456c118939872 (diff)
Fixed #13567 -- Added a 'silent' argument to the cycle tag, so that you can declare a cycle without producing a value in the template. Thanks to anentropic for the suggestion and initial patch, and Łukasz Rekucki for the final patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14439 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/templates/builtins.txt20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 7bb4481904..5fdef71a5f 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -140,6 +140,26 @@ In this syntax, each value gets interpreted as a literal string, and there's no
way to specify variable values. Or literal commas. Or spaces. Did we mention
you shouldn't use this syntax in any new projects?
+.. versionadded:: 1.3
+
+By default, when you use the ``as`` keyword with the cycle tag, the
+usage of ``{% cycle %}`` that declares the cycle will itself output
+the first value in the cycle. This could be a problem if you want to
+use the value in a nested loop or an included template. If you want to
+just declare the cycle, but not output the first value, you can add a
+``silent`` keyword as the last keyword in the tag. For example::
+
+ {% cycle 'row1' 'row2' as rowcolors silent %}
+ {% for obj in some_list %}
+ <tr class="{% cycle rowcolors %}">{{ obj }}</tr>
+ {% endfor %}
+
+This will output a list of ``<tr>`` elements with ``class``
+alternating between ``row1`` and ``row2``. If the ``silent`` keyword
+were to be omitted, ``row1`` would be emitted as normal text, outside
+the list of ``<tr>`` elements, and the first ``<tr>`` would have a
+class of ``row2``.
+
.. templatetag:: debug
debug