From 9c89bbbec71020e3d3e1b1fe99445654576a5538 Mon Sep 17 00:00:00 2001 From: Thomas van Noort Date: Fri, 22 Nov 2013 12:24:52 +0100 Subject: [PATCH] Add equalto test as value-level analogue of reference-level sameas test. --- jinja2/tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jinja2/tests.py b/jinja2/tests.py index 87b31201..7b57d1dc 100644 --- a/jinja2/tests.py +++ b/jinja2/tests.py @@ -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 } -- 2.47.3