From: Thomas van Noort Date: Fri, 22 Nov 2013 11:24:52 +0000 (+0100) Subject: Add equalto test as value-level analogue of reference-level sameas test. X-Git-Tag: 2.8~101^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c89bbbec71020e3d3e1b1fe99445654576a5538;p=thirdparty%2Fjinja.git Add equalto test as value-level analogue of reference-level sameas test. --- 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 }