如何制作只包含jinja模板的python包

如何制作只包含jinja模板的python包,python,flask,pip,packages,jinja2,Python,Flask,Pip,Packages,Jinja2,目前有一个项目,我正在尝试扩展jinja2模板,该模板位于我试图制作的python包中。现在我正在努力制作一个包含.html文件的python包。以下是我目前拥有的: sharedtemplates/ ├── setup.py └── templates ├── __init__.py ├── base.html ├── footer.html └── header.html \uuuu init\uuuu.py为空,setup.py为超基本 我当前使用的目录设

目前有一个项目,我正在尝试扩展jinja2模板,该模板位于我试图制作的python包中。现在我正在努力制作一个包含
.html
文件的python包。以下是我目前拥有的:

sharedtemplates/
├── setup.py
└── templates
    ├── __init__.py
    ├── base.html
    ├── footer.html
    └── header.html
\uuuu init\uuuu.py
为空,
setup.py
为超基本

我当前使用的目录设置如下:

repo/
├── site.py
└── templates
    └── index.html
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/中的templates目录,首先加载当前repo目录中的templates/目录


谢谢。

我忘了安装python setup.py。我需要把模板放到另一个模板目录中。所以它是sharedtemplates/templates/templates/base.html。确实需要进行一些重命名和重构

你有什么问题?@Celeo抱歉,我应该说得更清楚些。我一直担心找不到模块。我的sharetemplates/模块中是否有我需要的特定内容。据我所知,其他一切似乎都没问题。我忘了安装
python setup.py
。我需要把模板放到另一个模板目录中。所以它是
sharedtemplates/templates/templates/base.html
。肯定需要做一些重命名和重构