Fixed #25031 -- Fixed a regression in the unordered_list template filter.
This commit is contained in:
parent
2e70bf3785
commit
e291fc4757
|
@ -683,11 +683,14 @@ def unordered_list(value, autoescape=True):
|
|||
|
||||
def walk_items(item_list):
|
||||
item_iterator = iter(item_list)
|
||||
for item in item_iterator:
|
||||
try:
|
||||
item = next(item_iterator)
|
||||
while True:
|
||||
try:
|
||||
next_item = next(item_iterator)
|
||||
except StopIteration:
|
||||
next_item = None
|
||||
yield item, None
|
||||
break
|
||||
if not isinstance(next_item, six.string_types):
|
||||
try:
|
||||
iter(next_item)
|
||||
|
@ -695,10 +698,12 @@ def unordered_list(value, autoescape=True):
|
|||
pass
|
||||
else:
|
||||
yield item, next_item
|
||||
item = next(item_iterator)
|
||||
continue
|
||||
yield item, None
|
||||
if next_item:
|
||||
yield next_item, None
|
||||
item = next_item
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
def list_formatter(item_list, tabs=1):
|
||||
indent = '\t' * tabs
|
||||
|
|
|
@ -89,3 +89,6 @@ Bugfixes
|
|||
* Fixed inline forms that use a parent object that has a ``UUIDField`` primary
|
||||
key and a child object that has an ``AutoField`` primary key
|
||||
(:ticket:`24958`).
|
||||
|
||||
* Fixed a regression in the ``unordered_list`` template filter on certain
|
||||
inputs (:ticket:`25031`).
|
||||
|
|
|
@ -83,6 +83,13 @@ class FunctionTests(SimpleTestCase):
|
|||
'</li>\n\t</ul>\n\t</li>\n\t<li>item 2</li>',
|
||||
)
|
||||
|
||||
def test_nested3(self):
|
||||
self.assertEqual(
|
||||
unordered_list(['item 1', 'item 2', ['item 2.1']]),
|
||||
'\t<li>item 1</li>\n\t<li>item 2\n\t<ul>\n\t\t<li>item 2.1'
|
||||
'</li>\n\t</ul>\n\t</li>',
|
||||
)
|
||||
|
||||
def test_nested_multiple(self):
|
||||
self.assertEqual(
|
||||
unordered_list(['item 1', ['item 1.1', ['item 1.1.1', ['item 1.1.1.1']]]]),
|
||||
|
|
Loading…
Reference in New Issue