当前位置: 首页>>代码示例>>Python>>正文


Python utils.get_app_template_dirs方法代码示例

本文整理汇总了Python中django.template.utils.get_app_template_dirs方法的典型用法代码示例。如果您正苦于以下问题:Python utils.get_app_template_dirs方法的具体用法?Python utils.get_app_template_dirs怎么用?Python utils.get_app_template_dirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.template.utils的用法示例。


在下文中一共展示了utils.get_app_template_dirs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: template_dirs

# 需要导入模块: from django.template import utils [as 别名]
# 或者: from django.template.utils import get_app_template_dirs [as 别名]
def template_dirs(self):
        """
        Returns a list of directories to search for templates.
        """
        # Immutable return value because it's cached and shared by callers.
        template_dirs = tuple(self.dirs)
        if self.app_dirs:
            template_dirs += get_app_template_dirs(self.app_dirname)
        return template_dirs 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:11,代码来源:base.py

示例2: get_template_sources

# 需要导入模块: from django.template import utils [as 别名]
# 或者: from django.template.utils import get_app_template_dirs [as 别名]
def get_template_sources(self, template_name, template_dirs=None):
        """
        Returns the absolute paths to "template_name", when appended to each
        directory in "template_dirs". Any paths that don't lie inside one of the
        template dirs are excluded from the result set, for security reasons.
        """
        if not template_dirs:
            template_dirs = get_app_template_dirs('templates')
        for template_dir in template_dirs:
            try:
                yield safe_join(template_dir, template_name)
            except SuspiciousFileOperation:
                # The joined path was located outside of this template_dir
                # (it might be inside another one, so this isn't fatal).
                pass 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:17,代码来源:app_directories.py

示例3: template_dirs

# 需要导入模块: from django.template import utils [as 别名]
# 或者: from django.template.utils import get_app_template_dirs [as 别名]
def template_dirs(self):
        """
        Return a list of directories to search for templates.
        """
        # Immutable return value because it's cached and shared by callers.
        template_dirs = tuple(self.dirs)
        if self.app_dirs:
            template_dirs += get_app_template_dirs(self.app_dirname)
        return template_dirs 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:11,代码来源:base.py

示例4: get_dirs

# 需要导入模块: from django.template import utils [as 别名]
# 或者: from django.template.utils import get_app_template_dirs [as 别名]
def get_dirs(self):
        return get_app_template_dirs('templates') 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:4,代码来源:app_directories.py

示例5: list_templates

# 需要导入模块: from django.template import utils [as 别名]
# 或者: from django.template.utils import get_app_template_dirs [as 别名]
def list_templates(request):
    template_dirs = [s for s in get_app_template_dirs('templates') if re.match(r'.*/karrot/.*', s)]

    template_names = set()

    templates = {}

    for directory in template_dirs:
        for directory, dirnames, filenames in os.walk(directory):
            relative_dir = directory[len(basedir) + 1:]
            for filename in filenames:
                if re.match(r'.*\.jinja2$', filename) and not re.match(r'.*\.nopreview\.jinja2$', filename):
                    path = os.path.join(relative_dir, filename)

                    # strip out anything past the first dot for the name
                    name = re.sub(r'\..*$', '', os.path.basename(path))

                    if name != 'template_preview_list':
                        template_names.add(name)

                        formats = []

                        for idx, s in enumerate(['subject', 'text', 'html']):
                            if os.path.isfile('{}.{}.jinja2'.format(os.path.join(directory, name), s)):
                                formats.append(s)
                            elif s == 'text':
                                formats.append('autotext')

                        # only include if some formats were defined (even empty ones would end up with autotext...)
                        if len(formats) > 1:
                            formats.append('raw')

                            templates[name] = {
                                'name': name,
                                'has_handler': name in dir(handlers),
                                'formats': formats,
                            }

    return HttpResponse(
        render_to_string(
            'template_preview_list.jinja2', {'templates': sorted(templates.values(), key=lambda t: t['name'])}
        )
    ) 
开发者ID:yunity,项目名称:karrot-backend,代码行数:45,代码来源:views.py


注:本文中的django.template.utils.get_app_template_dirs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。