mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #26118 -- Added 'is' operator to if template tag.
This commit is contained in:
committed by
Tim Graham
parent
a08d2463d2
commit
c00ae7f58c
@@ -527,3 +527,13 @@ class IfTagTests(SimpleTestCase):
|
||||
# A single equals sign is a syntax error.
|
||||
with self.assertRaises(TemplateSyntaxError):
|
||||
self.engine.render_to_string('if-tag-single-eq', {'foo': 1})
|
||||
|
||||
@setup({'template': '{% if foo is True %}yes{% else %}no{% endif %}'})
|
||||
def test_if_is_match(self):
|
||||
output = self.engine.render_to_string('template', {'foo': True})
|
||||
self.assertEqual(output, 'yes')
|
||||
|
||||
@setup({'template': '{% if foo is True %}yes{% else %}no{% endif %}'})
|
||||
def test_if_is_no_match(self):
|
||||
output = self.engine.render_to_string('template', {'foo': 1})
|
||||
self.assertEqual(output, 'no')
|
||||
|
||||
Reference in New Issue
Block a user