
Django snippets: Smart {% if %} template tag - jacquesm
http://www.djangosnippets.org/snippets/1350/
======
apgwoz
This is good. Of course, this is how the if tag _should_ work in django to
begin with.

~~~
jacquesm
agreed. The 'crippling' has gone a bit too far I think, I can see the reason
why they want to limit what you can do within a template but to not have the
ability to combine expressions gets tedious really quickly.

The argument seems to be that a template designer should not be able to break
the site, that's not a very strong one because after all any brace or % sign
removed will break the site just fine.

~~~
yummyfajitas
I'm not entirely sure how

    
    
        {% if a == b %}
    

will break the site, but

    
    
        {% ifequal a b %}
    

will not. Maybe if someone destructively overloads __eq__?

~~~
jacquesm
I figure if I were a template designer I would treat anything between { and }
as if it were radioactive.

------
DocSavage
I wound up ditching Django templates for Jinja 2 in my app engine sites. No
regrets. There was just enough irritation with Django templating issues (e.g.,
the if implementation, filter arguments) that I swapped in Jinja. This article
has been posted before but I figure it's pertinent to the OP:

[http://lucumr.pocoo.org/2008/9/16/why-jinja-is-not-django-
an...](http://lucumr.pocoo.org/2008/9/16/why-jinja-is-not-django-and-why-
django-should-have-a-look-at-it)

