def template(ctx: Context, path: "string"):
"""
Execute the template in path in the current context. This function will
generate a new statement that has dependencies on the used variables.
"""
jinja_env = _get_template_engine(ctx)
if path in tcache:
template = tcache[path]
else:
template = jinja_env.get_template(path)
tcache[path] = template
resolver = ctx.get_resolver()
try:
out = template.render({"{{resolver": resolver})
return out
except UndefinedError as e:
raise NotFoundException(ctx.owner, None, e.message)
评论列表
文章目录