jinja.py 文件源码

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

项目:incubator-ariatosca 作者: apache 项目源码 文件源码
def read(self):
        data = self.load()
        try:
            data = unicode(data)
            template = Template(data)
            literal = template.render(CONTEXT)
            # TODO: might be useful to write the literal result to a file for debugging
            location = self.location
            if isinstance(location, basestring) and location.endswith('.jinja'):
                # Use reader based on the location with the ".jinja" prefix stripped off
                location = location[:-6]
                next_reader = self.context.reading.reader_source.get_reader(
                    self.context, LiteralLocation(literal, name=location), LiteralLoader(literal))
            else:
                # Use reader for literal loader
                next_reader = self.context.reading.reader_source.get_reader(
                    self.context, LiteralLocation(literal), LiteralLoader(literal))
            return next_reader.read()
        except Exception as e:
            raise ReaderSyntaxError(u'Jinja: {0}'.format(e), cause=e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号