- # mark active
- for d in result:
- if 'dropdown' in d:
- for dd in d['contents']:
- if dd['label'] == current: dd['is_active']=True
- else:
- if d['label'] == current: d['is_active']=True
+ # mark active if the provided 'current', even if shorter, matches the beginning of d['label']
+
+ if current is not None:
+ current=current.lower()
+ curlen=len(current)
+ def mark_active(d):
+ if d['label'][:curlen].lower() == current: d['is_active']=True
+ for d in result:
+ mark_active(d)
+ if 'dropdown' in d:
+ for dd in d['contents']: mark_active(dd)