From 62d91d67f3b96ce7412d747ab3dd60a3aecc8276 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 17 Jun 2011 02:45:57 +0200 Subject: [PATCH] More documentation updates --- docs/blueprints.rst | 28 +++++++++++++++++++++++++++- flask/app.py | 7 ++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/blueprints.rst b/docs/blueprints.rst index 8a83128d..d1ee7963 100644 --- a/docs/blueprints.rst +++ b/docs/blueprints.rst @@ -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. diff --git a/flask/app.py b/flask/app.py index 41eea79d..dcc6daed 100644 --- a/flask/app.py +++ b/flask/app.py @@ -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 """