【发布时间】:2013-01-29 15:22:09
【问题描述】:
我有以下代码:
from jinja2 import Template
templ_str = "lots of garbly html" # Compiled by external logic
templ_context = ast.literal_eval(context_dir) # Compiled by external logic
template = Template(templ_str)
template.render(**context)
模板的主体被即时编译并传递给模板引擎。但是,我想从文件中使用基本包装器扩展该模板。我知道这可以通过 FileSystemLoader 完成,但我需要从内存中加载我的主模板,而不是从文件中。
从 API 文档来看,这似乎是不可行的。有什么解决方法吗?
【问题讨论】:
标签: python django django-templates jinja2