Ticket #3184: defaultfilters.diff

File defaultfilters.diff, 1.1 KB (added by dummy@…, 18 years ago)

better unordered_list

  • django/template/defaultfilters.py

     
    289289    """
    290290    def _helper(value, tabs):
    291291        indent = '\t' * tabs
    292         if value[1]:
    293             return '%s<li>%s\n%s<ul>\n%s\n%s</ul>\n%s</li>' % (indent, value[0], indent,
    294                 '\n'.join([_helper(v, tabs+1) for v in value[1]]), indent, indent)
     292        if type(value) is type([]):
     293            if value[1]:
     294                if type(value[1]) is type([]):
     295                    return '%s<li>%s\n%s<ul>\n%s\n%s</ul>\n%s</li>' % (indent, value[0], indent,
     296                        '\n'.join([_helper(v, tabs+1) for v in value[1]]), indent, indent)
     297                else:
     298                    return '\n'.join([_helper(v, tabs) for v in value])
     299            else:
     300                return('%s<li>%s</li>' % (indent, value[0]))
    295301        else:
    296             return '%s<li>%s</li>' % (indent, value[0])
     302            return('%s<li>%s</li>' % (indent, value))
     303
    297304    return _helper(value, 1)
    298305
    299306###################
Back to Top