Am 27.09.2008 um 04:40 schrieb Malcolm Tredinnick:
> On Wed, 2008-09-24 at 16:34 +0200, Johannes Dollinger wrote:
> [...]
>> tpl.render(Context({}, loader=PrefixLoader(['a', 'b', 'c'])))
>> }}}
>>
>> This would fix #2949, #3544, #4278, #6834, and #7931. But it's a
>> backwards incompatible change: If you rely on compile time side
>> effects (e.g. {% load %}) in included templates, that will break.
>>
>> Opinions?
>
> -1 from me, since it's backwards incompatible. It looks like most of
> those feature requests (or at least the ones that are worth doing --
> it's not clear that things like #3944 are worth it) can be done  
> without
> backwards incompatible behavioural changes.

Every instance of {% include "foo.html" %} would behave as {% with  
"foo.html" as tpl_name %}{% include tpl_name %}{% endwith %}.
The difference should be an implementation detail - currently it's not.

Recursive includes (#3544) are useful whenever you render trees:
#node.xml:
<node>
        <label>{{ node.label }}</label>
        {% for child in node.children %}
                {% with child as node %}
                        {% include "node.xml" %}
                {% endwith %}
        {% endfor %}
</node>

You can already do that if you hack around ConstantIncludeNode with {%  
with "node.xml" as tpl %}{% include tpl %}{% endwith %}.
ContantIncludeNode is also the problem in #7931 (which I don't really  
care about).

<advertisment>
With #7817 [1] you could write:
[...]
{% for child in node.children %}
        {% include "node.xml" with child as node %}
{% endfor %}
[...]
</advertisment>

However, my original motivation for the proposed change was  
customizing the loader for individual requests: while you can pick a  
loader for the root Template, you have no control over {% include %}  
and {% extends %} template loading. That's essentially what #2949 and  
#6834 are about.

> The template context is the static rendering context, not the
> compiling/loading context and it feels like this is blurring that
> boundary.

Context would be the loading context *while rendering*, is that too  
far fetched?

[1] http://code.djangoproject.com/ticket/7817



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