Make the menu html serializer pass LI items through as-is (allows for separators), issue github 55, thanks Jonathan Bohren

This commit is contained in:
mdipierro
2013-02-10 17:12:44 -06:00
parent ae12b74620
commit aaa379ead0
2 changed files with 30 additions and 27 deletions

View File

@@ -1 +1 @@
Version 2.4.1-alpha.2+timestamp.2013.02.08.13.01.03
Version 2.4.1-alpha.2+timestamp.2013.02.10.17.11.46

View File

@@ -2328,34 +2328,37 @@ class MENU(DIV):
else:
ul = UL(_class=self['ul_class'])
for item in data:
(name, active, link) = item[:3]
if isinstance(link, DIV):
li = LI(link)
elif 'no_link_url' in self.attributes and self['no_link_url'] == link:
li = LI(DIV(name))
elif isinstance(link,dict):
li = LI(A(name, **link))
elif link:
li = LI(A(name, _href=link))
elif not link and isinstance(name, A):
li = LI(name)
if isinstance(item,LI):
ul.append(item)
else:
li = LI(A(name, _href='#',
_onclick='javascript:void(0);return false;'))
if level == 0 and item == data[0]:
li['_class'] = self['li_first']
elif level == 0 and item == data[-1]:
li['_class'] = self['li_last']
if len(item) > 3 and item[3]:
li['_class'] = self['li_class']
li.append(self.serialize(item[3], level + 1))
if active or ('active_url' in self.attributes and self['active_url'] == link):
if li['_class']:
li['_class'] = li['_class'] + ' ' + self['li_active']
(name, active, link) = item[:3]
if isinstance(link, DIV):
li = LI(link)
elif 'no_link_url' in self.attributes and self['no_link_url'] == link:
li = LI(DIV(name))
elif isinstance(link,dict):
li = LI(A(name, **link))
elif link:
li = LI(A(name, _href=link))
elif not link and isinstance(name, A):
li = LI(name)
else:
li['_class'] = self['li_active']
if len(item) <= 4 or item[4] == True:
ul.append(li)
li = LI(A(name, _href='#',
_onclick='javascript:void(0);return false;'))
if level == 0 and item == data[0]:
li['_class'] = self['li_first']
elif level == 0 and item == data[-1]:
li['_class'] = self['li_last']
if len(item) > 3 and item[3]:
li['_class'] = self['li_class']
li.append(self.serialize(item[3], level + 1))
if active or ('active_url' in self.attributes and self['active_url'] == link):
if li['_class']:
li['_class'] = li['_class'] + ' ' + self['li_active']
else:
li['_class'] = self['li_active']
if len(item) <= 4 or item[4] == True:
ul.append(li)
return ul
def serialize_mobile(self, data, select=None, prefix=''):