1 from django.template import TemplateDoesNotExist
2 from django.template.loader import BaseLoader
3 from django.utils.encoding import smart_unicode
5 from philo.models import Template
8 class Loader(BaseLoader):
10 :class:`philo.loaders.database.Loader` enables loading of template code from :class:`.Template`\ s. This would let :class:`.Template`\ s be used with ``{% include %}`` and ``{% extends %}`` tags, as well as any other features that use template loading.
15 def load_template_source(self, template_name, template_dirs=None):
17 template = Template.objects.get_with_path(template_name)
18 except Template.DoesNotExist:
19 raise TemplateDoesNotExist(template_name)
20 return (template.code, smart_unicode(template))