attribute.rst 466B

12345678910111213141516171819
  1. ``attribute``
  2. =============
  3. .. versionadded:: 1.2
  4. The ``attribute`` function was added in Twig 1.2.
  5. ``attribute`` can be used to access a "dynamic" attribute of a variable:
  6. .. code-block:: jinja
  7. {{ attribute(object, method) }}
  8. {{ attribute(object, method, arguments) }}
  9. {{ attribute(array, item) }}
  10. .. note::
  11. The resolution algorithm is the same as the one used for the ``.``
  12. notation, except that the item can be any valid expression.