1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

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
This commit is contained in:
Adrian Holovaty
2005-11-22 05:44:04 +00:00
parent 1ba8bd114a
commit bedf10a98d
3 changed files with 86 additions and 1 deletions

View File

@@ -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