#13567: cycle tag with 'as' shouldn't return a value
-----------------------------+----------------------------------------------
 Reporter:  anentropic       |       Owner:  nobody    
   Status:  new              |   Milestone:            
Component:  Template system  |     Version:  SVN       
 Keywords:                   |       Stage:  Unreviewed
Has_patch:  1                |  
-----------------------------+----------------------------------------------
 if you use the 'as' form of the cycle tag, eg:
 {{{
     {% cycle 'odd' 'even' as row_class %}
 }}}
 ...that cycle tag still outputs a string at that point in the template.
 Usually tags which set a context variable don't return a value - if you
 want to output the value you can do that separately with {{ row_class }}

 It's unhelpful in the following use case:
 {{{
     <table>
     {% for item in outer_loop %}
         {% cycle 'even' 'odd' as row_class %}
         {% for row in inner_loop %}
             <tr class="{{ row_class }}">
         {% endfor %}
     {% endfor %}
     </table>
 }}}
 i.e. you want to cycle values based on the outer loop, but they have to be
 output from within the inner loop. AFAIK you can't use the cycle tag
 within the inner loop as it'll pick up the wrong loop.

 The code above works, but you also get 'odd even odd even odd even odd
 even...' appearing above the table, with no way to avoid it.

 I think if you use the 'as' form it shouldn't output a value. Patch
 attached.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13567>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to