Please also get a look at http://github.com/buriy/django-containers
Which implements exactly the same, but allows larger chunks:
{% part left%}{% trans "arbitrary contents" %}{% endpart %}.
--
Best regards, Yuri V. Baburov, ICQ# 99934676, Skype: yuri.baburov,
MSN: bu...@live.com
> I'd like to propose adding a tag that includes a template with clean
> context, but can accept parameters that will be added to that
> context.
Is there a reason to do this as a separate tag? Why not just::
{% include "some/template.html" with foo=bar baz=spam %}
?
Jacob
--
Łukasz Rekucki
what about:
{% include "some/template.html" with foo=bar baz=spam %}
=> adds varaibles 'foo' and 'baz' to current context
{% include "some/template.html" withonly foo=bar baz=spam %}
=> replaces current context with one having just 'foo' and 'baz'
--
Javier
I also use {% with %}{% include %} a lot in templates but we should
follow with/blocktrans syntax for consistency:
{% include "part.html" with obj.title|capfirst as title and "large"
as main_class %}
A related proposal for the "with" tag: It'd be nice to support more
than one variable definition (as blocktrans does):
{% with "a" as var1 and "b" as var2 %}...{% endwith %}
The current solution is nesting "with" tags, which is not very pretty.
gonz.
2010/6/8 Marco Louro <mlo...@gmail.com>:
[...]
> A related proposal for the "with" tag: It'd be nice to support more
> than one variable definition (as blocktrans does):
>
> {% with "a" as var1 and "b" as var2 %}...{% endwith %}
>
> The current solution is nesting "with" tags, which is not very pretty.
>
As the next step to make something happen is to create a ticket, I
found this on trac: http://code.djangoproject.com/ticket/7817
I'm willing to improve the existing patch, so I assigned it to myself.
The ticket is marked as DDN, so I guess this thread is a request to
accept it.
--
Łukasz Rekucki
{% include "part.html" title=obj.title|capfirst main_class="large" %}
This is both more dense, and from quick grasp you can see where are
the delimiters ("as" is not so good for this).
Also I think we need an argument to tell that outer context is passed inside.
> --
> You received this message because you are subscribed to the Google Groups "Django developers" group.
> To post to this group, send email to django-d...@googlegroups.com.
> To unsubscribe from this group, send email to django-develop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Bye default it should keep its behaviour and use the current context
for the included template. Marco's use of a new, clean context
(demonstrated with the snippet below) is also possible to support.
{% if label %}
<label>{{ label }}</label>
{% else %}
You can just pass in an empty string, like one of the following three examples:
{% include "part.html" with label= title=obj.title %}
{% include "part.html" with label="" title=obj.title %}
{% include "part.html" with "" as label and obj.title as title %}
(I don't want to propose the implementation of all three syntaxes. I
just want to demonstrate that all possible syntaxes can handle Marco's
usecase.)
--
Servus,
Gregor Müllegger
2010/6/8 bur...@gmail.com <bur...@gmail.com>: