I found the culprit, http://code.djangoproject.com/svn/django/trunk/django/template/defaulttags.py line 507: " if not hasattr(parser, '_namedCycleNodes'):" Parser is template specific, but making cycle not work is stupid since I noticed something else too, the variable *is* passed to included template but not the knowledge how to cycle it. Thus this is possible:
list.html: <!-- {% cycle 'odd' 'even' as rowcolors %} --> ... {% include "list_item.html" %} ... list_item.html {{ rowcolors }} That does work, but it won't cycle as one could expect. I'm now trying to found a way to make it cycle in included template too. On 31 touko, 13:52, Jari Pennanen <jari.penna...@gmail.com> wrote: > Hi! > > Is there reason why cycle must be in the *same* template, and not for > instance in parent template? There are usecases: > > list.html: > {% cycle 'row1' 'row2' as rowcolors %} > <table> > <tr> > <th>..</th> > <th>..</th> > <th>..</th> > </tr> > {% for item in object_list %} > {% include "list_item.html" %} > {% endfor %} > </table> > > list_item.html: > <tr class="{% cycle rowcolors %}"> > <td>..</td> > <td>..</td> > <td>..</td> > </tr> > > Throws the error that rowcolors is not defined, meaning it won't get > passed to list_item.html. > > Use case: > > For obvious reasons one cannot but the rowcolors inside list_item.html > since there can be list.html that implements multiple loops etc, like > this: > complicated_list.html: > {% cycle 'row1' 'row2' as rowcolors %} > <table> > <tr> > <th>..</th> > <th>..</th> > <th>..</th> > </tr> > {% for item in object_list %} > {% include "list_item.html" %} > {% endfor %} > ... > {% for item in object_list_highlighted %} > {% include "list_item.html" %} > {% endfor %} > </table> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---