Skip to content

Commit

Permalink
[#847] Add note about undefined variables in Jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Nov 28, 2013
1 parent e7324b9 commit d361dc8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions doc/theming/templates.rst
Expand Up @@ -250,6 +250,27 @@ any template file:

.. todo:: Insert cross-ref to custom config options section.

.. note::

If a template tries to render a variable or attribute that doesn't exist,
rather than crashing or giving an error message, the Jinja2 expression
simply evaluates to nothing (an empty string). For example, these Jinja2
expressions will output nothing::

{{ app_globals.an_attribute_that_does_not_exist }}

{{ a_variable_that_does_not_exist }}

If, on the other hand, you try to render an attribute of a variable that
doesn't exist, then Jinja2 will crash. For example, this Jinja2 expression
will crash with an
``UndefinedError: 'a_variable_that_does_not_exist' is undefined``:

{{ a_variable_that_does_not_exist.an_attribute_that_does_not_exist }}

See the `Jinja2 docs <http://jinja.pocoo.org/docs/templates/#variables>`_
for details.

.. note::

Jinja2 expressions can do much more than print out the values of variables,
Expand Down

0 comments on commit d361dc8

Please sign in to comment.