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):
|
def walk_items(item_list):
|
||||||
item_iterator = iter(item_list)
|
item_iterator = iter(item_list)
|
||||||
for item in item_iterator:
|
try:
|
||||||
|
item = next(item_iterator)
|
||||||
|
while True:
|
||||||
try:
|
try:
|
||||||
next_item = next(item_iterator)
|
next_item = next(item_iterator)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
next_item = None
|
yield item, None
|
||||||
|
break
|
||||||
if not isinstance(next_item, six.string_types):
|
if not isinstance(next_item, six.string_types):
|
||||||
try:
|
try:
|
||||||
iter(next_item)
|
iter(next_item)
|
||||||
|
@ -695,10 +698,12 @@ def unordered_list(value, autoescape=True):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
yield item, next_item
|
yield item, next_item
|
||||||
|
item = next(item_iterator)
|
||||||
continue
|
continue
|
||||||
yield item, None
|
yield item, None
|
||||||
if next_item:
|
item = next_item
|
||||||
yield next_item, None
|
except StopIteration:
|
||||||
|
pass
|
||||||
|
|
||||||
def list_formatter(item_list, tabs=1):
|
def list_formatter(item_list, tabs=1):
|
||||||
indent = '\t' * tabs
|
indent = '\t' * tabs
|
||||||
|
|
|
@ -89,3 +89,6 @@ Bugfixes
|
||||||
* Fixed inline forms that use a parent object that has a ``UUIDField`` primary
|
* Fixed inline forms that use a parent object that has a ``UUIDField`` primary
|
||||||
key and a child object that has an ``AutoField`` primary key
|
key and a child object that has an ``AutoField`` primary key
|
||||||
(:ticket:`24958`).
|
(: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>',
|
'</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):
|
def test_nested_multiple(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
unordered_list(['item 1', ['item 1.1', ['item 1.1.1', ['item 1.1.1.1']]]]),
|
unordered_list(['item 1', ['item 1.1', ['item 1.1.1', ['item 1.1.1.1']]]]),
|
||||||
|
|
Loading…
Reference in New Issue