blob: 448c238bcaad4d6f2f57b7e410057846f243b879 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001``constant``
2============
3
4``constant`` checks if a variable has the exact same value as a constant. You
5can use either global constants or class constants:
6
7.. code-block:: twig
8
9 {% if post.status is constant('Post::PUBLISHED') %}
10 the status attribute is exactly the same as Post::PUBLISHED
11 {% endif %}
12
13You can test constants from object instances as well:
14
15.. code-block:: twig
16
17 {% if post.status is constant('PUBLISHED', post) %}
18 the status attribute is exactly the same as Post::PUBLISHED
19 {% endif %}