#13567: cycle tag with 'as' shouldn't return a value
---------------------------------------------+------------------------------
          Reporter:  anentropic              |         Owner:  nobody
            Status:  new                     |     Milestone:        
         Component:  Template system         |       Version:  SVN   
        Resolution:                          |      Keywords:        
             Stage:  Design decision needed  |     Has_patch:  1     
        Needs_docs:  0                       |   Needs_tests:  0     
Needs_better_patch:  0                       |  
---------------------------------------------+------------------------------
Comment (by anentropic):

 Here's a new patch so that cycle will accept a 'silent mode' flag as an
 arg after the variable name. eg
 {{{
 {% cycle 'row1' 'row2' 'row3' as rowcolors 1 %}
 }}}
 If the flag isn't present the tag behaves as before, if the flag evaluates
 True then it suppresses the output.

 Once I got into doing it I discovered I think the reason why the tag was
 built so that the 'as' form still outputs a value. It's not explained very
 clearly in the docs, but when you use the 'by name' form:
 {{{
 {% cycle rowcolors %}
 }}}
 ...you are re-using the actual cycle tag (with 'as') that you created
 earlier, and expecting it to output a value.  I guess it's useful
 sometimes, but a bit confusing as this is different to how other tags
 work.

 Anyway, with this new patch the cycle tag will work exactly as before,
 unless you specify the 'silent' flag. In that case the 'by name' form
 won't be useful but I guess people can live with that.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13567#comment:2>
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