Reputation: 1505
What is the scope of custom tags loaded using load in django templating system especially w.r.t Template Inheritance?
How can you effectively load the same custom tag in a tree of template hierarchy. I couldn't find either of the info in docs. Any pointers would be useful.
Thanks.
Upvotes: 4
Views: 777
Reputation: 7932
I also wondered about this and found the documentation lacking, so I decided to do some testing on my own.
As of django 1.4, the answer is: the scope of a loaded custom tag is limited strictly to the file it is loaded in (using {% load %}
) and absolutely nothing else.
The following attempts to use a custom tag have failed:
extend
s Template B:
include
s Template B:
with context
So yeah, it is strictly a per-file thing (which is good because it makes it impossible to squirrel in mystery tags from a distance - unless of course you do so on purpose by messing with the global loader (which you shouldn't))
Upvotes: 7