Ticket #500: optional_template_file_extensions.diff
File optional_template_file_extensions.diff, 3.3 KB (added by , 19 years ago) |
---|
-
django/conf/global_settings.py
91 91 # List of locations of the template source files, in search order. 92 92 TEMPLATE_DIRS = () 93 93 94 # Extension on all templates.94 # Default extension for templates if none is given. 95 95 TEMPLATE_FILE_EXTENSION = '.html' 96 96 97 97 # List of callables that know how to import templates from various sources. -
django/core/template/loaders/app_directories.py
28 28 app_template_dirs = tuple(app_template_dirs) 29 29 30 30 def get_template_sources(template_name, template_dirs=None): 31 if not os.path.splitext(template_name): 32 # Only append TEMPLATE_FILE_EXTENSION if there isn't an extension already. 33 template_name = template_name + TEMPLATE_FILE_EXTENSION 31 34 for template_dir in app_template_dirs: 32 yield os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION35 yield os.path.join(template_dir, template_name) 33 36 34 37 def load_template_source(template_name, template_dirs=None): 35 38 for filepath in get_template_sources(template_name, template_dirs): -
django/core/template/loaders/eggs.py
7 7 8 8 from django.core.template import TemplateDoesNotExist 9 9 from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION 10 import os 10 11 11 12 def load_template_source(template_name, template_dirs=None): 12 13 """ … … 15 16 For every installed app, it tries to get the resource (app, template_name). 16 17 """ 17 18 if resource_string is not None: 18 pkg_name = 'templates/' + template_name + TEMPLATE_FILE_EXTENSION 19 if not os.path.splitext(template_name): 20 # Only append TEMPLATE_FILE_EXTENSION if there isn't an extension already. 21 template_name = template_name + TEMPLATE_FILE_EXTENSION 22 pkg_name = 'templates/' + template_name 19 23 for app in INSTALLED_APPS: 20 24 try: 21 25 return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name)) -
django/core/template/loaders/filesystem.py
7 7 def get_template_sources(template_name, template_dirs=None): 8 8 if not template_dirs: 9 9 template_dirs = TEMPLATE_DIRS 10 if not os.path.splitext(template_name): 11 # Only append TEMPLATE_FILE_EXTENSION if there isn't an extension already. 12 template_name = template_name + TEMPLATE_FILE_EXTENSION 10 13 for template_dir in template_dirs: 11 yield os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION14 yield os.path.join(template_dir, template_name) 12 15 13 16 def load_template_source(template_name, template_dirs=None): 14 17 tried = []