diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-11-22 05:44:04 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-11-22 05:44:04 +0000 |
| commit | bedf10a98dfe46dda39e8a20530f7476e7df90ff (patch) | |
| tree | d58b5a6cd01dabcb69ef9f498188bbd71be5ad95 /docs/templates.txt | |
| parent | 1ba8bd114a487350bd47283fa067bbb80e6a66aa (diff) | |
Fixed #598 -- Added {% include %} template tag. Added docs and unit tests. Thanks, rjwittams
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1349 bcc190cf-cafb-0310-a4f2-bffc1f526a37
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 |
