forked from orbit-oss/flask
More documentation updates
This commit is contained in:
parent
abe1378cae
commit
62d91d67f3
2 changed files with 33 additions and 2 deletions
|
|
@ -147,4 +147,30 @@ the `template_folder` parameter to the :class:`Blueprint` constructor::
|
|||
admin = Blueprint('admin', __name__, template_folder='templates')
|
||||
|
||||
As for static files, the path can be absolute or relative to the blueprint
|
||||
resource folder.
|
||||
resource folder. The template folder is added to the searchpath of
|
||||
templates but with a lower priority than the actual application's template
|
||||
folder. That way you can easily override templates that a blueprint
|
||||
provides in the actual application.
|
||||
|
||||
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
|
||||
``templates`` as a `template_folder` you will have to create a file like
|
||||
this: ``yourapplication/admin/templates/admin/index.html``.
|
||||
|
||||
Building URLs
|
||||
-------------
|
||||
|
||||
If you want to link from one page to another you can use the
|
||||
:func:`url_for` function just like you normally would do just that you
|
||||
prefix the URL endpoint with the name of the blueprint and a dot (``.``)::
|
||||
|
||||
url_for('admin.index')
|
||||
|
||||
Additionally if you are in a view function of a blueprint or a rendered
|
||||
template and you want to link to another endpoint of the same blueprint,
|
||||
you can use relative redirects by prefixing the endpoint with a dot only::
|
||||
|
||||
url_for('.index')
|
||||
|
||||
This will link to ``admin.index`` for instance in case the current request
|
||||
was dispatched to any other admin blueprint endpoint.
|
||||
|
|
|
|||
|
|
@ -459,7 +459,12 @@ class Flask(_PackageBoundObject):
|
|||
|
||||
def create_global_jinja_loader(self):
|
||||
"""Creates the loader for the Jinja2 environment. Can be used to
|
||||
override just the loader and keeping the rest unchanged.
|
||||
override just the loader and keeping the rest unchanged. It's
|
||||
discouraged to override this function. Instead one should override
|
||||
the :meth:`create_jinja_loader` function instead.
|
||||
|
||||
The global loader dispatches between the loaders of the application
|
||||
and the individual blueprints.
|
||||
|
||||
.. versionadded:: 0.7
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue