Skip to content
Myr

More documentation updates

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent abe1378 · Browse files · 2 files+33 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+33 added−2 removed

  • other:+33 added−2 removed

2 files+33 added−2 removed

modified:docs/blueprints.rst+27 added-1 removed
145 unmodified lines
146147 admin = Blueprint('admin', __name__, template_folder='templates')148149As for static files, the path can be absolute or relative to the blueprint150resource folder.150resource folder. The template folder is added to the searchpath of151templates but with a lower priority than the actual application's template152folder. That way you can easily override templates that a blueprint153provides in the actual application.154155So if you have a blueprint in the folder ``yourapplication/admin`` and you156want to render the template ``'admin/index.html'`` and you have provided157``templates`` as a `template_folder` you will have to create a file like158this: ``yourapplication/admin/templates/admin/index.html``.159160Building URLs161-------------162163If you want to link from one page to another you can use the164:func:`url_for` function just like you normally would do just that you165prefix the URL endpoint with the name of the blueprint and a dot (``.``)::166167 url_for('admin.index')168169Additionally if you are in a view function of a blueprint or a rendered170template and you want to link to another endpoint of the same blueprint,171you can use relative redirects by prefixing the endpoint with a dot only::172173 url_for('.index')174175This will link to ``admin.index`` for instance in case the current request176was dispatched to any other admin blueprint endpoint.
modified:flask/app.py+6 added-1 removed
457 unmodified lines
458 return rv459460 def create_global_jinja_loader(self):461 """Creates the loader for the Jinja2 environment. Can be used to462 override just the loader and keeping the rest unchanged.462 override just the loader and keeping the rest unchanged. It's463 discouraged to override this function. Instead one should override464 the :meth:`create_jinja_loader` function instead.465466 The global loader dispatches between the loaders of the application467 and the individual blueprints.468469 .. versionadded:: 0.7470 """471 return DispatchingJinjaLoader(self)472
816 unmodified lines