aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/twig/twig/doc/functions/constant.rst
blob: bea0e9fc0b3bd43554c848c0de8e136738133c8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
``constant``
============

.. versionadded: 1.12.1
    constant now accepts object instances as the second argument.

``constant`` returns the constant value for a given string:

.. code-block:: jinja

    {{ some_date|date(constant('DATE_W3C')) }}
    {{ constant('Namespace\\Classname::CONSTANT_NAME') }}

As of 1.12.1 you can read constants from object instances as well:

.. code-block:: jinja

    {{ constant('RSS', date) }}