Files
Twig/doc/functions/constant.rst
T
Fabien Potencier 065b2e26a2 added missing docs
2016-11-12 17:36:55 -08:00

24 lines
487 B
ReStructuredText

``constant``
============
``constant`` returns the constant value for a given string:
.. code-block:: jinja
{{ some_date|date(constant('DATE_W3C')) }}
{{ constant('Namespace\\Classname::CONSTANT_NAME') }}
You can read constants from object instances as well:
.. code-block:: jinja
{{ constant('RSS', date) }}
Use the ``defined`` test to check if a constant is defined:
.. code-block:: jinja
{% if constant('SOME_CONST') is defined %}
...
{% endif %}