目前有一个项目,我正在尝试扩展jinja2模板,这些模板位于我试图制作的python包中。现在我正在努力制作一个包含.html
文件的python包。以下是我目前拥有的:
sharedtemplates/
├── setup.py
└── templates
├── __init__.py
├── base.html
├── footer.html
└── header.html
__init__.py
为空,setup.py
为超级基本。在
我当前使用的目录设置如下:
^{pr2}$在index.html
中,我需要{% extends 'base.html' %}
来扩展sharedtemplates
包中的base。在
site.py
中有这样的内容,可以优先加载模板:
template_loader = jinja2.ChoiceLoader([
jinja2.PackageLoader('reposhared', 'templates'),
app.jinja_loader
])
app.jinja_loader = template_loader
所以这将在sharedtemplates/首先在我当前的repo dir中加载templates目录。在
谢谢。在
我忘了做Python设置.py安装。我需要把模板放到另一个模板目录中。所以它就是sharedtemplates/templates/templates/基本.html. 当然需要做一些重命名和重构
相关问题 更多 >
编程相关推荐