On Sat, 2008-08-30 at 20:33 -0700, mmcduff wrote:
> I am trying to create a contents list using the following
> sidebar_sub_contents.html.
>
> {% for content in contents %}
> {% if content.link %}
> <li>
> <a href="{{ content.link }}">{{ content.name }}</a>
> </li>
> {% endif %}
> {% if content.list %}
> <ul>
> {% with content.list as contents %}
> {% include 'sidebar_sub_contents.html' %}
> {% endwith %}
> </ul>
> {% endif %}
> {% endfor %}
>
> The problem is that I get a maximum recursion runtime error. Even if
> I change the "if content.list" tag to a 'ifequal "0" "1"', I still get
> a max recursion error, suggesting that the template language is
> executed even if the conditions are not met. This doesn't seem right.
Whether it seems right or not, that is what happens. The template is
parsed at compile time and directives like "include" are processed then.
At rendering time the various if-conditions are tested and the right
branch taken. So, basically, the {% include %} tag is part of the
compilation process, not part of the rendering stage.
You can't do recursive includes with that tag. You will need to write
your own (although I wouldn't be too surprised if somebody else has
already done that) if you want to have recursive inclusions.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---