Code

Ticket #10067: tagload.diff

File tagload.diff, 1.5 KB (added by Ruediger Ranft <_rdi_@…>, 5 years ago)

Patch to add a module search path

Line 
1--- django/conf/global_settings.py.orig Mon Jan 19 09:27:37 2009
2+++ django/conf/global_settings.py      Mon Jan 19 09:28:37 2009
3@@ -169,6 +169,9 @@
4 # Output to use in template system for invalid (e.g. misspelled) variables.
5 TEMPLATE_STRING_IF_INVALID = ''
6 
7+# Base to search for tags to {% load %}
8+TEMPLATE_MODULES=( 'django.templatetags', )
9+
10 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
11 # trailing slash.
12 # Examples: "http://foo.com/media/", "/media/".
13--- django/template/defaulttags.py.orig Mon Jan 19 09:27:32 2009
14+++ django/template/defaulttags.py      Mon Jan 19 09:28:37 2009
15@@ -872,12 +872,17 @@
16     bits = token.contents.split()
17     for taglib in bits[1:]:
18         # add the library to the parser
19-        try:
20-            lib = get_library("django.templatetags.%s" % taglib)
21-            parser.add_library(lib)
22-        except InvalidTemplateLibrary, e:
23-            raise TemplateSyntaxError("'%s' is not a valid tag library: %s" %
24-                                      (taglib, e))
25+        resolved = False
26+        for mod in settings.TEMPLATE_MODULES:
27+            try:
28+                lib = get_library("%s.%s" % (mod, taglib))
29+                parser.add_library(lib)
30+                resolved = True
31+                break
32+            except InvalidTemplateLibrary:
33+                pass
34+        if not resolved:
35+            raise TemplateSyntaxError("'%s' is not a valid tag library" % taglib)
36     return LoadNode()
37 load = register.tag(load)
38