Ticket #10067: tagload.diff

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

Patch to add a module search path

  • django/conf/global_settings.py

    old new  
    169169# Output to use in template system for invalid (e.g. misspelled) variables.
    170170TEMPLATE_STRING_IF_INVALID = ''
    171171
     172# Base to search for tags to {% load %}
     173TEMPLATE_MODULES=( 'django.templatetags', )
     174
    172175# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
    173176# trailing slash.
    174177# Examples: "http://foo.com/media/", "/media/".
  • django/template/defaulttags.py

    old new  
    872872    bits = token.contents.split()
    873873    for taglib in bits[1:]:
    874874        # add the library to the parser
    875         try:
    876             lib = get_library("django.templatetags.%s" % taglib)
    877             parser.add_library(lib)
    878         except InvalidTemplateLibrary, e:
    879             raise TemplateSyntaxError("'%s' is not a valid tag library: %s" %
    880                                       (taglib, e))
     875        resolved = False
     876        for mod in settings.TEMPLATE_MODULES:
     877            try:
     878                lib = get_library("%s.%s" % (mod, taglib))
     879                parser.add_library(lib)
     880                resolved = True
     881                break
     882            except InvalidTemplateLibrary:
     883                pass
     884        if not resolved:
     885            raise TemplateSyntaxError("'%s' is not a valid tag library" % taglib)
    881886    return LoadNode()
    882887load = register.tag(load)
    883888
Back to Top