]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Add equalto test as value-level analogue of reference-level sameas test.
authorThomas van Noort <thomas@silkapp.com>
Fri, 22 Nov 2013 11:24:52 +0000 (12:24 +0100)
committerThomas van Noort <thomas@silkapp.com>
Fri, 22 Nov 2013 11:24:52 +0000 (12:24 +0100)
jinja2/tests.py

index 87b31201aeead2461e99c4875da08db63b8a6d80..7b57d1dc73e6cb0b6e50a46ce1bba82f8f233c2f 100644 (file)
@@ -102,6 +102,16 @@ def test_sequence(value):
         return False
     return True
 
+def test_equalto(value, other):
+    """Check if an object has the same value as another object:
+
+    .. sourcecode:: jinja
+
+        {% if foo.expression is equalto 42 %}
+            the foo attribute evaluates to the constant 42
+        {% endif %}
+    """
+    return value == other
 
 def test_sameas(value, other):
     """Check if an object points to the same memory address than another
@@ -146,5 +156,6 @@ TESTS = {
     'iterable':         test_iterable,
     'callable':         test_callable,
     'sameas':           test_sameas,
+    'equalto':          test_equalto,
     'escaped':          test_escaped
 }