But python also PARSES both branches of the given expression, so if
there was a SyntaxError, it would fail as well, the code doesn't get
run, as well as the template don't get rendered.

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

On Fri, May 16, 2008 at 8:40 PM, Joshua 'jag' Ginsberg
<[EMAIL PROTECTED]> wrote:
>
> Howdy --
>
> 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
>
> >
>



-- 
Honza Král
E-Mail: [EMAIL PROTECTED]
ICQ#: 107471613
Phone: +420 606 678585

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to