base.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:adhocracy4 作者: liqd 项目源码 文件源码
def render(self, template_name, context):
        languages = self.get_languages(context['receiver'])
        template = select_template([
            '{}.{}.email'.format(template_name, lang)
            for lang in languages
        ])

        # Get the actually chosen language from the template name
        language = template.template.name.split('.', 2)[-2]

        with translation.override(language):
            parts = []
            for part_type in ('subject', 'txt', 'html'):
                context['part_type'] = part_type
                parts.append(template.render(context))
                context.pop('part_type')

        return tuple(parts)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号