From f4c55791f71d164743d61f811c408b22e29ce8c8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 26 Nov 2010 19:14:17 +0100 Subject: [PATCH] added some example usage for the defined test in the doc --- doc/02-Twig-for-Template-Designers.markdown | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) 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 ---------- -- 1.7.2.5