diff options
| author | Preston Timmons <prestontimmons@gmail.com> | 2015-05-08 15:10:36 -0500 |
|---|---|---|
| committer | Preston Timmons <prestontimmons@gmail.com> | 2015-05-21 09:12:06 -0500 |
| commit | 655f52491505932ef04264de2bce21a03f3a7cd0 (patch) | |
| tree | c38eca24b887466fc2385fc773ff34247567c732 /docs/ref | |
| parent | 7b8008a078ffdfd18ebbe78fecbb92cdddf2f304 (diff) | |
Fixed #17085, #24783 -- Refactored template library registration.
* Converted the ``libraries`` and ``builtins`` globals of
``django.template.base`` into properties of the Engine class.
* Added a public API for explicit registration of libraries and builtins.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/templates/api.txt | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 4a9a73f758..6ff2dd6c7b 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -41,7 +41,7 @@ lower level APIs: Configuring an engine ===================== -.. class:: Engine([dirs][, app_dirs][, allowed_include_roots][, context_processors][, debug][, loaders][, string_if_invalid][, file_charset]) +.. class:: Engine([dirs][, app_dirs][, allowed_include_roots][, context_processors][, debug][, loaders][, string_if_invalid][, file_charset][, libraries][, builtins]) .. versionadded:: 1.8 @@ -114,6 +114,34 @@ Configuring an engine It defaults to ``'utf-8'``. + * ``'libraries'``: A dictionary of labels and dotted Python paths of template + tag modules to register with the template engine. This is used to add new + libraries or provide alternate labels for existing ones. For example:: + + Engine( + libraries={ + 'myapp_tags': 'path.to.myapp.tags', + 'admin.urls': 'django.contrib.admin.templatetags.admin_urls', + }, + ) + + Libraries can be loaded by passing the corresponding dictionary key to + the :ttag:`{% load %}<load>` tag. + + * ``'builtins'``: A list of dotted Python paths of template tag modules to + add to :doc:`built-ins </ref/templates/builtins>`. For example:: + + Engine( + builtins=['myapp.builtins'], + ) + + Tags and filters from built-in libraries can be used without first calling + the :ttag:`{% load %}<load>` tag. + +.. versionadded:: 1.9 + + The ``libraries`` and ``builtins`` arguments were added. + .. staticmethod:: Engine.get_default() When a Django project configures one and only one |
