diff options
| author | Tim Graham <timograham@gmail.com> | 2013-01-01 08:12:42 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-01-02 18:50:00 -0500 |
| commit | be1e006c581cc45ed48ae0b423e7a0a996d2199b (patch) | |
| tree | 5e33669588d7c8d2a49d99f82ae87524d22a9455 /docs/ref/templates | |
| parent | 61c861546bdbae694f22e2c54e9ca0f42331cae1 (diff) | |
[1.5.x] Fixed #19516 - Fixed remaining broken links.
Added -n to sphinx builds to catch issues going forward.
Backport of 9b5f64cc6e from master.
Diffstat (limited to 'docs/ref/templates')
| -rw-r--r-- | docs/ref/templates/api.txt | 22 | ||||
| -rw-r--r-- | docs/ref/templates/builtins.txt | 2 |
2 files changed, 20 insertions, 4 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index db57d2de96..54f578a99f 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -558,15 +558,17 @@ Note that these paths should use Unix-style forward slashes, even on Windows. The Python API ~~~~~~~~~~~~~~ -Django has two ways to load templates from files: +.. module:: django.template.loader -.. function:: django.template.loader.get_template(template_name) +``django.template.loader`` has two functions to load templates from files: + +.. function:: get_template(template_name) ``get_template`` returns the compiled template (a ``Template`` object) for the template with the given name. If the template doesn't exist, it raises ``django.template.TemplateDoesNotExist``. -.. function:: django.template.loader.select_template(template_name_list) +.. function:: select_template(template_name_list) ``select_template`` is just like ``get_template``, except it takes a list of template names. Of the list, it returns the first template that exists. @@ -631,11 +633,19 @@ by editing your :setting:`TEMPLATE_LOADERS` setting. :setting:`TEMPLATE_LOADERS` should be a tuple of strings, where each string represents a template loader class. Here are the template loaders that come with Django: +.. currentmodule:: django.template.loaders + ``django.template.loaders.filesystem.Loader`` + +.. class:: filesystem.Loader + Loads templates from the filesystem, according to :setting:`TEMPLATE_DIRS`. This loader is enabled by default. ``django.template.loaders.app_directories.Loader`` + +.. class:: app_directories.Loader + Loads templates from Django apps on the filesystem. For each app in :setting:`INSTALLED_APPS`, the loader looks for a ``templates`` subdirectory. If the directory exists, Django looks for templates in there. @@ -670,12 +680,18 @@ class. Here are the template loaders that come with Django: This loader is enabled by default. ``django.template.loaders.eggs.Loader`` + +.. class:: eggs.Loader + Just like ``app_directories`` above, but it loads templates from Python eggs rather than from the filesystem. This loader is disabled by default. ``django.template.loaders.cached.Loader`` + +.. class:: cached.Loader + By default, the templating system will read and compile your templates every time they need to be rendered. While the Django templating system is quite fast, the overhead from reading and compiling templates can add up. diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 687e72a0e0..fadf2db161 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -370,7 +370,7 @@ block are output:: In the above, if ``athlete_list`` is not empty, the number of athletes will be displayed by the ``{{ athlete_list|length }}`` variable. -As you can see, the ``if`` tag may take one or several `` {% elif %}`` +As you can see, the ``if`` tag may take one or several ``{% elif %}`` clauses, as well as an ``{% else %}`` clause that will be displayed if all previous conditions fail. These clauses are optional. |
