Source

django-chameleon-templates / djchameleon / loaders / app_directories.py

Full commit
Kevin Veroneau a30b573 

















from chameleon import PageTemplateLoader
from django.template.loaders import app_directories
from .chameleon_tags import Template
from django.template.base import TemplateDoesNotExist
from django.conf import settings

class Loader(PageTemplateLoader, app_directories.Loader):
    is_usable = True
    def __init__(self, *args, **kwargs):
        template_dirs = app_directories.app_template_dirs
        self.formats.update({'xml': Template})
        default_extension = getattr(settings, 'CHAMELEON_EXTENSION', None)
        super(PageTemplateLoader, self).__init__(template_dirs, default_extension=default_extension, debug=settings.TEMPLATE_DEBUG)
    def load_template(self, template_name, template_dirs=None):
        try:
            template = self.load(template_name)
            return template, None
        except ValueError:
            raise TemplateDoesNotExist('Template not found: %s' % template_name)