In python, conditionals only evaluate the appropriate branch and only
after evaluating the condition. We can say:
if 'foo' in bar_dict:
print bar_dict['foo']
else:
print "Foo not in bar"
Even if bar_dict doesn't have a key 'foo' the first branch of the
conditional is not evaluated, and so a KeyError is not raised. Every
language does this.
However Django's template system evaluates the branches prior to
determining which will be followed. The following template will raise
a TemplateSyntaxError:
{% ifequal 0 1 %}{% load non_existant_tag_library %}{% endifequal %}
... because non_existant_tag_library doesn't exist. This should not
raise a TemplateSyntaxError.
I've submitted a patch on ticket #7251 to correct this. Thanks!
-jag
there are two distinct phases to template evaluation - parsing and
rendering, some tags (load for example) have some logic in the parsing
phase, if that fails, the parsing fails which acts the same way in
python - it dies in flames
--
Honza Král
E-Mail: Honza...@gmail.com
ICQ#: 107471613
Phone: +420 606 678585
-jag
-jag
On Sat, May 17, 2008 at 6:23 PM, Joshua 'jag' Ginsberg
but you need to load the library at parsing time to access the parsing
functions, there is no going around that... It might nit be ideal, but
I don't see any other way this could go with the current logic of
templates
-jag