flask-nav
flask-nav copied to clipboard
navbar not fully rendered in the example
Dear @mbr,
I like flask-nav, thanks for sharing this code with your insights. I have run into a minor issue. The example does not work completely; you don't get to see Widgets Inc. It seems like the first object of Navbar has no effect. I use flask 0.12.1. This is a navbar which does show Widgets inc and shows the problem.
nav.register_element(
'top',
Navbar(
None, # NOTE: here is the problem, what ever you put first has no effect
# if you put an object first it is not rendered
View('Widgits, Inc.', 'index'),
View('Our Mission', 'about'),
Subgroup('Products',
View('Wg240-Series',
'products',
product='wg240'),
View('Wg250-Series',
'products',
product='wg250'),
Separator(),
Text('Discontinued Products'),
View('Wg10X',
'products',
product='wg10x'), ),
Link('Tech Support', 'http://techsupport.invalid/widgits_inc'), ))
Yesterday, too, I ran into this problem. The reason for this behavior is as follows: class Navbar inherits from class Subgroup:
class Navbar(Subgroup): pass
, but class Subgroup when creating the first parameter takes the value of the title:
class Subgroup(NavigationItem): def __init__(self, title, *items): self.title = title self.items = list(items)