On Fri, Apr 21, 2006 at 09:38:56AM +0400, Ivan Sagalaev wrote:
> You use it then like this:
> 
>     {% product bestOffer %}
> 
> ... and bestOffer will be passed in product.html by the name 'product'.


And

On Fri, Apr 21, 2006 at 10:16:29PM +0800, limodou wrote in re:
Subject: New call tag

> It just like include, but in order to distinguish with
> "include" tag, I call it "call". So you can use it:
>
> {% call "some.html" %} this way just like include tag, and the advanced way:
>
> {% call "some.html" with "a" "b"|capfirst title="title1" %}
> {% call "some.html" with "c" "d" title="title2" %}
>
> So you can see, "call" tag can do like a python function, it can
> receive tuple parameters and key word parameters, just like the
> function:
>
> def func(*args, **kwargs):pass


There's a pattern here... a need for more "programability" in the templates.

I for one believe that templates should NOT have Python (in the case
of Django, or Ruby in the case of Rails) in them -- PERIOD!  A very
bad thing to do, security-wise.

The other pattern that emerges here is that there's a need for
being able to at least set variables from within a template.

I propose adding a tag to Django (i.e. not just "write your own
template", but make it, or something like this, a part of Django) for
just that purpose:

    {% set variable value %}
    where value is parsed so that it can be either a string
    or another variable name or of the form a.b.c etc.

in Ivan's case one would just do:
    {% set product bestOffer %}
    {% include product.html %}

and, in limodou's case one would just do:
    {% set title "title1" %}
    {% include some.html %}

This would allow one template to pass lists, or objects within
lists or whatever to other included templates.  It's not as
"elegant" as passing arguments to templates as what limodou
has done, but it will get that job done; be useful in other
ways; not have Python code in templates; and is fairly simple
and straightforward.

-- 
Glenn Tenney

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to