jinja模板扩展了相对/绝对路径

时间:2020-10-13 10:01:14

标签: python jinja2

我的文件夹结构看起来像

└── templates
    ├── base.html
    ├── foo
    │   ├── 1.html
    │   ├── 2.html
    └── bar
        ├── 1.html
        └── 2.html

如何使用base.html扩展1.html,2.html? “ ../”在模板内不起作用

{% extends "../base.html" %}

env = Environment(loader=FileSystemLoader('templates/%s/' % (channel == 0 and 'foo' or 'bar')))
templ = templateId + '.html'
templ = env.get_template(templ)
output = templ.render(data=data)

我得到{TemplateNotFound} ../ base.html

0 个答案:

没有答案