On Tue, 2009-03-24 at 05:36 -0700, Colm wrote:
[..]
> Assuming foo_app/template/template1 looks like this :
>
> {% include "path1/temtlate2" %}
>
> If template2 wants to include template3 should it do this :
>
> { % include "../path2/template3" %}
>
> OR this :
>
> {% include "path2/template3" %}
>
> From what you have said I'm gathering it is the latter. Is that
> correct?
Yes, it's the latter case. The second template has absolutely no
knowledge of being include by the first.
>
> Also, is the former idiom (the use of "..") meaningful at all when
> evaluating includes and if so what does it mean? If it is meaningful
> at all does it mean "relative to the templates directory"? i.e. if I
> had :
>
> templates/foo
> otherstuff/blah
>
> .. could I include "blah" by saying {% include "../otherstuff/blah"
> %}. Or does that not make sense?
The paths are resolved as relative paths against all the roots of the
template hierarchy. However, the resolution is constrainted to lie
*within* all those roots. So ../foo doesn't make sense unless you have
both "first/" and "first/second/" in the template hierarchy and
"first/foo" exists (since then it resolves as relative to first/second
and lands inside /first/ to find /first/foo).
People really shouldn't use paths like that, though. It's pretty
incomprehensible to others reading the templates.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---