Well, if you really need arbitrary logic in your templates, but like the
django template syntax, you should take a look at Mako[0], but it might
require some work in your views.
But this separation of presentation (logic) and (business) logic is
intentional, and if I have understood everything correctly, this is a result
of the whole MVC/MTV design pattern. And besides, I think the philosofy
stated in the docs is pretty good:

"Philosophy

If you have a background in programming, or if you're used to languages like
PHP which mix programming code directly into HTML, you'll want to bear in
mind that the Django template system is not simply Python embedded into
HTML. This is by design: the template system is meant to express
presentation, not program logic."
But sometimes, this lack of logic is very annoying, but I think it's worth
it. And it probably means less bugs, since I can't make any strange errors
in my templates :-)

Oscar

0. http://www.makotemplates.org/

On Sun, Jul 13, 2008 at 9:01 AM, Chris <[EMAIL PROTECTED]> wrote:

>
> Just out of curiosity, is there a reason why the templating constructs
> can't evaluate arbitrary expressions? It seems terribly awkward to me
> that {% if %} can only evaluate variable names, while you need the
> separate operator {% ifequals %} to test for equality, and for some
> reason it doesn't support {% else %}.
>
> I had a very simple use case where I wanted to do something like:
>
> {% if a == 1}blah{% else %}foo{% endif %}
>
> and the closest I can get is:
>
> {% ifequal a 1 %}blah{% endifequal %}{% ifnotequal a 1 %}foo{%
> endifnotequal %}
>
> Chris
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to