Yaffs site version 1.1
[yaffs-website] / vendor / twig / twig / doc / tests / constant.rst
diff --git a/vendor/twig/twig/doc/tests/constant.rst b/vendor/twig/twig/doc/tests/constant.rst
new file mode 100644 (file)
index 0000000..8d0724a
--- /dev/null
@@ -0,0 +1,22 @@
+``constant``
+============
+
+.. versionadded: 1.13.1
+    constant now accepts object instances as the second argument.
+
+``constant`` checks if a variable has the exact same value as a constant. You
+can use either global constants or class constants:
+
+.. code-block:: jinja
+
+    {% if post.status is constant('Post::PUBLISHED') %}
+        the status attribute is exactly the same as Post::PUBLISHED
+    {% endif %}
+
+You can test constants from object instances as well:
+
+.. code-block:: jinja
+
+    {% if post.status is constant('PUBLISHED', post) %}
+        the status attribute is exactly the same as Post::PUBLISHED
+    {% endif %}