6
6
resource_string = None
8
8
from django.template import TemplateDoesNotExist
9
from django.template.loader import BaseLoader
9
10
from django.conf import settings
12
class Loader(BaseLoader):
13
is_usable = resource_string is not None
15
def load_template_source(self, template_name, template_dirs=None):
17
Loads templates from Python eggs via pkg_resource.resource_string.
19
For every installed app, it tries to get the resource (app, template_name).
21
if resource_string is not None:
22
pkg_name = 'templates/' + template_name
23
for app in settings.INSTALLED_APPS:
25
return (resource_string(app, pkg_name).decode(settings.FILE_CHARSET), 'egg:%s:%s' % (app, pkg_name))
28
raise TemplateDoesNotExist(template_name)
11
32
def load_template_source(template_name, template_dirs=None):
13
Loads templates from Python eggs via pkg_resource.resource_string.
15
For every installed app, it tries to get the resource (app, template_name).
17
if resource_string is not None:
18
pkg_name = 'templates/' + template_name
19
for app in settings.INSTALLED_APPS:
21
return (resource_string(app, pkg_name).decode(settings.FILE_CHARSET), 'egg:%s:%s' % (app, pkg_name))
24
raise TemplateDoesNotExist, template_name
35
"'django.template.loaders.eggs.load_template_source' is deprecated; use 'django.template.loaders.eggs.Loader' instead.",
36
PendingDeprecationWarning
38
return _loader.load_template_source(template_name, template_dirs)
25
39
load_template_source.is_usable = resource_string is not None