diff options
Diffstat (limited to 'docs/templates.txt')
| -rw-r--r-- | docs/templates.txt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/templates.txt b/docs/templates.txt index bf229ee6b7..53df12e6a0 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -492,6 +492,40 @@ ifnotequal Just like ``ifequal``, except it tests that the two arguments are not equal. +include +~~~~~~~ + +**Only available in Django development version.** + +Loads a template and renders it with the current context. This is a way of +"including" other templates within a template. + +The template name can either be a variable or a hard-coded (quoted) string, +in either single or double quotes. + +This example includes the contents of the template ``"foo/bar"``:: + + {% include "foo/bar" %} + +This example includes the contents of the template whose name is contained in +the variable ``template_name``:: + + {% include template_name %} + +An included template is rendered with the context of the template that's +including it. This example produces the output ``"Hello, John"``: + + * Context: variable ``person`` is set to ``"john"``. + * Template:: + + {% include "name_snippet" %} + + * The ``name_snippet`` template:: + + Hello, {{ person }} + +See also: ``{% ssi %}``. + load ~~~~ @@ -645,6 +679,8 @@ file are evaluated as template code, within the current context:: Note that if you use ``{% ssi %}``, you'll need to define `ALLOWED_INCLUDE_ROOTS`_ in your Django settings, as a security measure. +See also: ``{% include %}``. + .. _ALLOWED_INCLUDE_ROOTS: http://www.djangoproject.com/documentation/settings/#allowed-include-roots templatetag |
