From: Armin Ronacher Date: Thu, 12 Dec 2013 22:32:44 +0000 (+0000) Subject: Added a note on why equalto exists. X-Git-Tag: 2.8~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6c6fe4382dd54ea8ace77300e387652bfbbde6b;p=thirdparty%2Fjinja.git Added a note on why equalto exists. --- diff --git a/jinja2/tests.py b/jinja2/tests.py index 7b57d1dc..96967f92 100644 --- a/jinja2/tests.py +++ b/jinja2/tests.py @@ -102,6 +102,7 @@ def test_sequence(value): return False return True + def test_equalto(value, other): """Check if an object has the same value as another object: @@ -110,9 +111,18 @@ def test_equalto(value, other): {% if foo.expression is equalto 42 %} the foo attribute evaluates to the constant 42 {% endif %} + + This appears to be a useless test as it does exactly the same as the + ``==`` operator, but it can be useful when used together with the + `selectattr` function: + + .. sourcecode:: jinja + + {{ users|selectattr("email", "equalto", "foo@bar.invalid") }} """ return value == other + def test_sameas(value, other): """Check if an object points to the same memory address than another object: