added some example usage for the defined test in the doc
authorFabien Potencier <fabien.potencier@gmail.com>
Fri, 26 Nov 2010 18:14:17 +0000 (19:14 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Fri, 26 Nov 2010 18:14:17 +0000 (19:14 +0100)
doc/02-Twig-for-Template-Designers.markdown

index b0b8ef7..abc5038 100644 (file)
@@ -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
 ----------