]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Added a note on why equalto exists.
authorArmin Ronacher <armin.ronacher@active-4.com>
Thu, 12 Dec 2013 22:32:44 +0000 (22:32 +0000)
committerArmin Ronacher <armin.ronacher@active-4.com>
Thu, 12 Dec 2013 22:32:44 +0000 (22:32 +0000)
jinja2/tests.py

index 7b57d1dc73e6cb0b6e50a46ce1bba82f8f233c2f..96967f927f7a6e40ebe614efc49909e8b544ba7b 100644 (file)
@@ -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: