Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right side navbar #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion flask_bootstrap/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
from dominate import tags
from visitor import Visitor

try:
# Try to import Separator from flask elements as we need it in visit_Navbar
# to use a isinstance.
from flask_nav.elements import Separator
except ImportError:

# flask-nav is not installed, Separator won't be handled
# TODO: Will this code be even called is navbar is not installed ?
def is_separator_instance(instance):
return False
else:

# flask-nav is installed, go for a valid check!
def is_separator_instance(instance):
return isinstance(instance, Separator)


class BootstrapRenderer(Visitor):
def __init__(self, html5=True, id=None):
Expand Down Expand Up @@ -50,7 +66,11 @@ def visit_Navbar(self, node):
bar_list = bar.add(tags.ul(_class='nav navbar-nav'))

for item in node.items:
bar_list.add(self.visit(item))
if is_separator_instance(item):
ul_tag = tags.ul(_class='nav navbar-nav navbar-right')
bar_list = bar.add(ul_tag)
else:
bar_list.add(self.visit(item))

return root

Expand Down