#5865: cycle template tag should accept a single argument
------------------------+---------------------------------------------------
   Reporter:  gwilson   |                Owner:  munhitsu       
     Status:  reopened  |            Component:  Template system
    Version:  SVN       |           Resolution:                 
   Keywords:            |                Stage:  Accepted       
  Has_patch:  1         |           Needs_docs:  1              
Needs_tests:  0         |   Needs_better_patch:  0              
------------------------+---------------------------------------------------
Changes (by munhitsu):

  * needs_better_patch:  1 => 0

Comment:

 Replying to [comment:9 gwilson]:

 Thanks for the comments.
   1. Functionality for test cycle20 updated. Do you have an idea how to
 prepare context with non iterable variable? I have no clue how to make
 unit test for it.
 {{{
 'cycle20': ("{% cycle colors %}", {'colors': 'r'}, 'r')
 }}}
   2. Regarding silent fail... Actual implementation will throw
 !TemplateSyntaxError for test cycle01 as original one. But i.e if 'a'
 would be defined in context than it will fall back to
 Variable('a').resolve(context).
 {{{
 'cycle01': ('{% cycle a %}', {}, template.TemplateSyntaxError)
 }}}
   3. I've just added !NameError exception catch as a backup to make sure
 we will fail silently
   4. Cycle patch now iterates over everything that is iterable - see test
 cycle22. It's hashed as Python does not guarantee iteration sequence on
 hash.
 {{{
 'cycle22': ("{% cycle colors %}{% cycle colors %}", {'colors': {'r': 1,
 'g': 2}}, 'rg')
 }}}
   5. Regarding cycle internal state in tag. I must say that I was inspired
 by !ForNode and cycle is a somehow close to it. Take a look at tests
 cycle28..29. That the only reasonable case that I see now to use cycle
 internals. It's your choice.
 {{{
 'cycle28': ("{% for i in test %}{% cycle colors %}{{ cycle.value }}{{ i
 }},{% endfor %}", {'test': range(5),'colors': ['r', 'g', 'b']},
 'rr0,gg1,bb2,rr3,gg4,'),
 'cycle29': ("{% for i in test %}{% cycle colors %}{% cycle colors %}{{ i
 }},{% endfor %}", {'test': range(5),'colors': ['r', 'g', 'b']},
 'rg0,br1,gb2,rg3,br4,'),
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5865#comment:10>
Django Code <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