forked from orbit-oss/flask
Mention the template name conflict issue in blueprint templates docs (#1843)
* Mention the template name conflict issue in docs. In the blueprints templates documentation mention the possible templates name conflict issue re #266 * Mention priorities between blueprints and other rephrasing fixes
This commit is contained in:
parent
bbd6c8c791
commit
9c236d3b84
1 changed files with 15 additions and 6 deletions
|
|
@ -176,16 +176,25 @@ the `template_folder` parameter to the :class:`Blueprint` constructor::
|
||||||
|
|
||||||
admin = Blueprint('admin', __name__, template_folder='templates')
|
admin = Blueprint('admin', __name__, template_folder='templates')
|
||||||
|
|
||||||
As for static files, the path can be absolute or relative to the blueprint
|
For static files, the path can be absolute or relative to the blueprint
|
||||||
resource folder. The template folder is added to the searchpath of
|
resource folder.
|
||||||
templates but with a lower priority than the actual application's template
|
|
||||||
folder. That way you can easily override templates that a blueprint
|
The template folder is added to the search path of templates but with a lower
|
||||||
provides in the actual application.
|
priority than the actual application's template folder. That way you can
|
||||||
|
easily override templates that a blueprint provides in the actual application.
|
||||||
|
This also means that if you don't want a blueprint template to be accidentally
|
||||||
|
overridden, make sure that no other blueprint or actual application template
|
||||||
|
has the same relative path. When multiple blueprints provide the same relative
|
||||||
|
template path the first blueprint registered takes precedence over the others.
|
||||||
|
|
||||||
|
|
||||||
So if you have a blueprint in the folder ``yourapplication/admin`` and you
|
So if you have a blueprint in the folder ``yourapplication/admin`` and you
|
||||||
want to render the template ``'admin/index.html'`` and you have provided
|
want to render the template ``'admin/index.html'`` and you have provided
|
||||||
``templates`` as a `template_folder` you will have to create a file like
|
``templates`` as a `template_folder` you will have to create a file like
|
||||||
this: :file:`yourapplication/admin/templates/admin/index.html`.
|
this: :file:`yourapplication/admin/templates/admin/index.html`. The reason
|
||||||
|
for the extra ``admin`` folder is to avoid getting our template overridden
|
||||||
|
by a template named ``index.html`` in the actual application template
|
||||||
|
folder.
|
||||||
|
|
||||||
To further reiterate this: if you have a blueprint named ``admin`` and you
|
To further reiterate this: if you have a blueprint named ``admin`` and you
|
||||||
want to render a template called :file:`index.html` which is specific to this
|
want to render a template called :file:`index.html` which is specific to this
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue