#12162: cycle should have an option to call value without actually cycling
--------------------------------------+-------------------------------------
          Reporter:  ka...@yahoo.com  |         Owner:  nobody
            Status:  new              |     Milestone:        
         Component:  Template system  |       Version:  1.1   
        Resolution:                   |      Keywords:        
             Stage:  Unreviewed       |     Has_patch:  0     
        Needs_docs:  0                |   Needs_tests:  0     
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Changes (by Alex):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Old description:

> Hear me out. :)  My use case is this: I have a large table, I have
> already ordered the objects that will make up each row according to a
> certain key attribute. What I would like to do is use the 'cycle' tag
> together with the 'ifchanged' tag to change the bg-color of the rows only
> when this key attribute has changed. E.g.:
>
> (blue) New Mexico John ...
> (blue) New Mexico Jill ...
> (blue) New Mexico Jeff ...
> (green) Texas Jack ...
> (green) Texas Jane ...
> (blue) Arizona James ...
> ...
>
> But, it just can't be done (in the template) as things stand. Every
> access of the 'cycle' tag (whether named or not) gives the next value in
> the cycle. I propose an alternate tag that picks up the cycle variable
> without changing it from its last appearance. Then code like this ought
> to be able to accomplish the task:
>
> {% ifchanged state %}
>   <tr style="background:{% cycle 'blue' 'green' as rowbg %};">
> {% else %}
>   <tr style="background:{% dontcycle rowbg %};">
> {% endifchanged %}
>
> I really believe this is a legitimate presentation task. Thanks for your
> consideration.     K.C.S.

New description:

 Hear me out. :)  My use case is this: I have a large table, I have already
 ordered the objects that will make up each row according to a certain key
 attribute. What I would like to do is use the 'cycle' tag together with
 the 'ifchanged' tag to change the bg-color of the rows only when this key
 attribute has changed. E.g.:
 {{{
 (blue) New Mexico John ...
 (blue) New Mexico Jill ...
 (blue) New Mexico Jeff ...
 (green) Texas Jack ...
 (green) Texas Jane ...
 (blue) Arizona James ...
 ...
 }}}
 But, it just can't be done (in the template) as things stand. Every access
 of the 'cycle' tag (whether named or not) gives the next value in the
 cycle. I propose an alternate tag that picks up the cycle variable without
 changing it from its last appearance. Then code like this ought to be able
 to accomplish the task:
 {{{
 {% ifchanged state %}
   <tr style="background:{% cycle 'blue' 'green' as rowbg %};">
 {% else %}
   <tr style="background:{% dontcycle rowbg %};">
 {% endifchanged %}
 }}}
 I really believe this is a legitimate presentation task. Thanks for your
 consideration.     K.C.S.

Comment:

 Please use preview.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12162#comment:1>
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 django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to