Fixed #19882 -- Smarter tokenizing of {% for %} tag arguments.
This commit is contained in:
parent
5488437ab6
commit
f13bfbec70
|
@ -746,7 +746,7 @@ def do_for(parser, token):
|
||||||
========================== ================================================
|
========================== ================================================
|
||||||
|
|
||||||
"""
|
"""
|
||||||
bits = token.contents.split()
|
bits = token.split_contents()
|
||||||
if len(bits) < 4:
|
if len(bits) < 4:
|
||||||
raise TemplateSyntaxError("'for' statements should have at least four"
|
raise TemplateSyntaxError("'for' statements should have at least four"
|
||||||
" words: %s" % token.contents)
|
" words: %s" % token.contents)
|
||||||
|
|
|
@ -833,6 +833,8 @@ class Templates(TestCase):
|
||||||
'for-tag-empty01': ("{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}", {"values": [1, 2, 3]}, "123"),
|
'for-tag-empty01': ("{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}", {"values": [1, 2, 3]}, "123"),
|
||||||
'for-tag-empty02': ("{% for val in values %}{{ val }}{% empty %}values array empty{% endfor %}", {"values": []}, "values array empty"),
|
'for-tag-empty02': ("{% for val in values %}{{ val }}{% empty %}values array empty{% endfor %}", {"values": []}, "values array empty"),
|
||||||
'for-tag-empty03': ("{% for val in values %}{{ val }}{% empty %}values array not found{% endfor %}", {}, "values array not found"),
|
'for-tag-empty03': ("{% for val in values %}{{ val }}{% empty %}values array not found{% endfor %}", {}, "values array not found"),
|
||||||
|
# Ticket 19882
|
||||||
|
'for-tag-filter-ws': ("{% for x in ''|add:'a b c' %}{{ x }}{% endfor %}", {}, 'a b c'),
|
||||||
|
|
||||||
### IF TAG ################################################################
|
### IF TAG ################################################################
|
||||||
'if-tag01': ("{% if foo %}yes{% else %}no{% endif %}", {"foo": True}, "yes"),
|
'if-tag01': ("{% if foo %}yes{% else %}no{% endif %}", {"foo": True}, "yes"),
|
||||||
|
|
Loading…
Reference in New Issue