Show template names in markup

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
from django.template import TemplateDoesNotExist
from django.conf import settings

def load_template_source(template_name, template_dirs=None):
    if not template_dirs:
        template_dirs = settings.TEMPLATE_DIRS

    for template_dir in template_dirs:
        template_location = "%s/%s" % (template_dir, template_name)
        try:
            file_contents = open(template_location).read()
            header = "<span style='font-family:Verdana; font-size:9px;'>&nbsp;template: <u>%s</u></span><br/>" % template_name
            file_contents = header + file_contents
            return (file_contents, template_name)
        except IOError:
            continue
        raise TemplateDoesNotExist, template_name
    
load_template_source.is_usable = True

More like this

  1. Plaintext format (advanced spaceless) by hoverhell 2 years, 1 month ago
  2. themed_template_loader by amitu 4 years, 2 months ago
  3. Language aware template loader by rmt 4 years, 1 month ago
  4. Dynamic Template Loader by jgeewax 4 years, 10 months ago
  5. assigning many partially deviant variables by justinlilly 5 years, 11 months ago

Comments

(Forgotten your password?)