Monday, March 7, 2011

Cycle & Include tags

I'm using a recent checkout of Django trunk.

If I have a template "test.html" which is this:

{{ rowcolors }}

the only way I could make cycle and include behave together is to do
this:

{% for obj in page.object_list %}
<!-- {% cycle 'odd' 'even' as rowcolors %} -->
{% include 'test.html' %}
{% endfor %}

I thought that perhaps the new "silent" keyword would eliminate the
need to HTML comment out the cycle tag:

{% for obj in page.object_list %}
{% cycle 'odd' 'even' as rowcolors silent %}
{% include 'test.html' %}
{% endfor %}

However, the very first time through the for loop, rowcolors is not
set in the included template. It works on subsequent cycles though.

Is there a way to make this work without having to HTML comment out
the cycle tag output? Admittedly it's a minor annoyance.

Thanks!

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate