From: Fabien Potencier Date: Fri, 26 Nov 2010 18:14:17 +0000 (+0100) Subject: added some example usage for the defined test in the doc X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=f4c55791f71d164743d61f811c408b22e29ce8c8;p=konrad%2Ftwig.git added some example usage for the defined test in the doc --- diff --git a/doc/02-Twig-for-Template-Designers.markdown b/doc/02-Twig-for-Template-Designers.markdown index b0b8ef7..abc5038 100644 --- a/doc/02-Twig-for-Template-Designers.markdown +++ b/doc/02-Twig-for-Template-Designers.markdown @@ -1307,7 +1307,18 @@ can use either global constants or class constants: ### `defined` `defined` checks if a variable is defined in the current context. This is very -useful if you use the `strict_variables` option. +useful if you use the `strict_variables` option: + + [twig] + {# defined works with variable names #} + {% if foo is defined %} + ... + {% endif %} + + {# and attributes on variables names #} + {% if foo.bar is defined %} + ... + {% endif %} Extensions ----------