1``attribute`` 2============= 3 4.. versionadded:: 1.2 5 The ``attribute`` function was added in Twig 1.2. 6 7The ``attribute`` function can be used to access a "dynamic" attribute of a 8variable: 9 10.. code-block:: jinja 11 12 {{ attribute(object, method) }} 13 {{ attribute(object, method, arguments) }} 14 {{ attribute(array, item) }} 15 16In addition, the ``defined`` test can check for the existence of a dynamic 17attribute: 18 19.. code-block:: jinja 20 21 {{ attribute(object, method) is defined ? 'Method exists' : 'Method does not exist' }} 22 23.. note:: 24 25 The resolution algorithm is the same as the one used for the ``.`` 26 notation, except that the item can be any valid expression. 27