Ticket #12965: unordered_list.diff
File unordered_list.diff, 1.5 KB (added by , 15 years ago) |
---|
-
django/template/defaultfilters.py
602 602 first_item, second_item = list_ 603 603 if second_item == []: 604 604 return [first_item], True 605 try: 606 it = iter(second_item) # see if second item is iterable 607 except TypeError: 608 return list_, False 605 609 old_style_list = True 606 610 new_second_item = [] 607 611 for sublist in second_item: -
tests/regressiontests/defaultfilters/tests.py
347 347 >>> unordered_list(['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]) 348 348 u'\t<li>States\n\t<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>Lawrence</li>\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>\n\t\t<li>Illinois</li>\n\t</ul>\n\t</li>' 349 349 350 >>> class ULItem(object): 351 ... def __init__(self, title): 352 ... self.title = title 353 ... def __unicode__(self): 354 ... return u'ulitem-%s' % str(self.title) 355 356 >>> a = ULItem('a') 357 >>> b = ULItem('b') 358 >>> unordered_list([a,b]) 359 u'\t<li>ulitem-a</li>\n\t<li>ulitem-b</li>' 360 350 361 # Old format for unordered lists should still work 351 362 >>> unordered_list([u'item 1', []]) 352 363 u'\t<li>item 1</li>'