Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MiltonLn committed Jan 31, 2018
2 parents dccc1f8 + 4d8d3be commit 905fc5c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions menu_generator/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,20 @@ def _get_url(self, item_dict):

def _is_selected(self, item_dict):
"""
Given a menu item dictionary, it returns true if `url` is on path.
Given a menu item dictionary, it returns true if `url` is on path,
unless the item is marked as a root, in which case returns true if `url` is part of path.
"""
url = self._get_url(item_dict)
return url == self.path
if self._is_root(item_dict):
return url in self.path
else:
return url == self.path

def _is_root(self, item_dict):
"""
Given a menu item dictionary, it returns true if item is marked as a `root`.
"""
return item_dict.get('root', False)

def _process_breadcrums(self, menu_list):
"""
Expand Down

0 comments on commit 905fc5c

Please sign in to comment.