From d70860f5f5263ec8aa7d8f81729ff79793985a6b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 18 Jul 2012 09:53:29 +0200 Subject: [PATCH] added a note about accessing variable attributes that contains operators (closes #775) --- doc/templates.rst | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/doc/templates.rst b/doc/templates.rst index cf6d19d..c37e5c6 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -74,6 +74,15 @@ properties of a PHP object, or items of a PHP array), or the so-called {{ foo.bar }} {{ foo['bar'] }} +When the attribute contains special characters (like ``-`` that would be +interpreted as the minus operator), use the ``attribute`` function instead to +access the variable attribute: + +.. code-block:: jinja + + {# equivalent to the non-working foo.data-foo #} + {{ attribute(foo, 'data-foo') }} + .. note:: It's important to know that the curly braces are *not* part of the -- 1.7.2.5