diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-09-14 02:49:21 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-09-14 02:49:21 +0000 |
| commit | 09145d2e5f1445d59d0c121394b78ec5ed196056 (patch) | |
| tree | fffad80fef39a29cd64a42036bb0db0e9fd5a1c1 /docs | |
| parent | a2ce7669d902cf32eeac9307b804b78ed4150fe5 (diff) | |
Fixed #208 -- Modernized the syntax of the cycle tag to allow for spaces and variables in cycle values. Thanks to SmileyChris and Chris McAvoy for their work on this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6153 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/templates.txt | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/docs/templates.txt b/docs/templates.txt index 9f2bec1c8b..ff67579b87 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -366,25 +366,36 @@ Ignore everything between ``{% comment %}`` and ``{% endcomment %}`` cycle ~~~~~ -Cycle among the given strings each time this tag is encountered. +**Changed in Django development version** +Cycle among the given strings or variables each time this tag is encountered. -Within a loop, cycles among the given strings each time through the loop:: +Within a loop, cycles among the given strings/variables each time through the +loop:: {% for o in some_list %} - <tr class="{% cycle row1,row2 %}"> + <tr class="{% cycle 'row1' 'row2' rowvar %}"> ... </tr> {% endfor %} - + Outside of a loop, give the values a unique name the first time you call it, then use that name each successive time through:: - <tr class="{% cycle row1,row2,row3 as rowcolors %}">...</tr> + <tr class="{% cycle 'row1' 'row2' rowvar as rowcolors %}">...</tr> <tr class="{% cycle rowcolors %}">...</tr> <tr class="{% cycle rowcolors %}">...</tr> -You can use any number of values, separated by commas. Make sure not to put -spaces between the values -- only commas. +You can use any number of values, separated by spaces. Values enclosed in +single (') or double quotes (") are treated as string literals, while values +without quotes are assumed to refer to context variables. + +You can also separate values with commas:: + + {% cycle row1,row2,row3 %} + +In this syntax, each value will be interpreted as literal text. The +comma-based syntax exists for backwards-compatibility, and should not be +used for new projects. debug ~~~~~ |
