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)
评论列表
文章目录