Yaffs site version 1.1
[yaffs-website] / vendor / twig / twig / doc / functions / attribute.rst
diff --git a/vendor/twig/twig/doc/functions/attribute.rst b/vendor/twig/twig/doc/functions/attribute.rst
new file mode 100644 (file)
index 0000000..ceba96b
--- /dev/null
@@ -0,0 +1,26 @@
+``attribute``
+=============
+
+.. versionadded:: 1.2
+    The ``attribute`` function was added in Twig 1.2.
+
+The ``attribute`` function can be used to access a "dynamic" attribute of a
+variable:
+
+.. code-block:: jinja
+
+    {{ attribute(object, method) }}
+    {{ attribute(object, method, arguments) }}
+    {{ attribute(array, item) }}
+
+In addition, the ``defined`` test can check for the existence of a dynamic
+attribute:
+
+.. code-block:: jinja
+
+    {{ attribute(object, method) is defined ? 'Method exists' : 'Method does not exist' }}
+
+.. note::
+
+    The resolution algorithm is the same as the one used for the ``.``
+    notation, except that the item can be any valid expression.