示例#1
0
文件: loaders.py 项目: cainlu/exjp
    def load_template(self, template_name, template_dirs=None):
        if not template_name.endswith(DEFAULT_JINJA2_TEMPLATE_EXTENSION):
            return super(LoaderMixin, self).load_template(template_name, template_dirs)

        try:
            template = env.get_template(template_name)
            return template, template.filename
        except jinja2.TemplateNotFound:
            raise TemplateDoesNotExist(template_name)
示例#2
0
 def load_template(self, template_name, template_dirs=None):
     if self.match_template(template_name):
         try:
             template = env.get_template(template_name)
             return template, template.filename
         except jinja2.TemplateNotFound:
             raise TemplateDoesNotExist(template_name)
     else:
         return super(LoaderMixin, self).load_template(template_name, template_dirs)
示例#3
0
 def load_template(self, template_name, template_dirs=None):
     if self.match_template(template_name):
         try:
             template = env.get_template(template_name)
             return template, template.filename
         except jinja2.TemplateNotFound:
             raise TemplateDoesNotExist(template_name)
     else:
         return super(LoaderMixin,
                      self).load_template(template_name, template_dirs)
示例#4
0
    def load_template(self, template_name, template_dirs=None):
        app_directories_loader = AppDirectoriesLoader()
        for skip_path in getattr(settings, 'KEEP_DJANGO_TEMPLATES', []):
            # Hackish way to use Django Loader for Django Admin
            if skip_path in template_name:
                return app_directories_loader(template_name, template_dirs)

        if not template_name.endswith(DEFAULT_JINJA2_TEMPLATE_EXTENSION):
            return super(LoaderMixin, self).load_template(template_name, template_dirs)

        try:
            template = env.get_template(template_name)
            return template, template.filename
        except jinja2.TemplateNotFound:
            raise TemplateDoesNotExist(template_name)
示例#5
0
    def load_template(self, template_name, template_dirs=None):
        app_directories_loader = AppDirectoriesLoader()
        for skip_path in getattr(settings, 'KEEP_DJANGO_TEMPLATES', []):
            # Hackish way to use Django Loader for Django Admin
            if skip_path in template_name:
                return app_directories_loader(template_name, template_dirs)

        if not template_name.endswith(DEFAULT_JINJA2_TEMPLATE_EXTENSION):
            return super(LoaderMixin,
                         self).load_template(template_name, template_dirs)

        try:
            template = env.get_template(template_name)
            return template, template.filename
        except jinja2.TemplateNotFound:
            raise TemplateDoesNotExist(template_name)
    def load_template(self, template_name, template_dirs=None):
        # If regex intercept is off (default), try
        # template intercept by extension.
        if (not RE_INTERCEPT_ON and
                not template_name.endswith(DEFAULT_JINJA2_TEMPLATE_EXTENSION)):
            return super(LoaderMixin, self).load_template(template_name, template_dirs)

        # If regex intercept is on, try regex match over
        # template name.
        elif RE_INTERCEPT_ON and not RE_INTERCEPT.match(template_name):
            return super(LoaderMixin, self).load_template(template_name, template_dirs)

        try:
            template = env.get_template(template_name)
            return template, template.filename
        except jinja2.TemplateNotFound:
            raise TemplateDoesNotExist(template_name)
示例#7
0
    def load_template(self, template_name, template_dirs=None):
        # If regex intercept is off (default), try
        # template intercept by extension.
        if (not RE_INTERCEPT_ON and
                not template_name.endswith(DEFAULT_JINJA2_TEMPLATE_EXTENSION)):
            return super(LoaderMixin, self).load_template(template_name, template_dirs)

        # If regex intercept is on, try regex match over
        # template name.
        elif RE_INTERCEPT_ON and not RE_INTERCEPT.match(template_name):
            return super(LoaderMixin, self).load_template(template_name, template_dirs)

        try:
            template = env.get_template(template_name)
            return template, template.filename
        except jinja2.TemplateNotFound:
            raise TemplateDoesNotExist(template_name)
示例#8
0
 def load_template(self, template_name, template_dirs=None):
     return env.get_template(template_name), template_name