diff options
Diffstat (limited to 'vendor/twig/twig/doc/tests/constant.rst')
-rw-r--r-- | vendor/twig/twig/doc/tests/constant.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vendor/twig/twig/doc/tests/constant.rst b/vendor/twig/twig/doc/tests/constant.rst new file mode 100644 index 00000000..8d0724a8 --- /dev/null +++ b/vendor/twig/twig/doc/tests/constant.rst | |||
@@ -0,0 +1,22 @@ | |||
1 | ``constant`` | ||
2 | ============ | ||
3 | |||
4 | .. versionadded: 1.13.1 | ||
5 | constant now accepts object instances as the second argument. | ||
6 | |||
7 | ``constant`` checks if a variable has the exact same value as a constant. You | ||
8 | can use either global constants or class constants: | ||
9 | |||
10 | .. code-block:: jinja | ||
11 | |||
12 | {% if post.status is constant('Post::PUBLISHED') %} | ||
13 | the status attribute is exactly the same as Post::PUBLISHED | ||
14 | {% endif %} | ||
15 | |||
16 | You can test constants from object instances as well: | ||
17 | |||
18 | .. code-block:: jinja | ||
19 | |||
20 | {% if post.status is constant('PUBLISHED', post) %} | ||
21 | the status attribute is exactly the same as Post::PUBLISHED | ||
22 | {% endif %} | ||