I am currently creating WebApp based on Flask, Bootstrap, and the Flask-Nav extension. I created a dynamic navigation bar that works great:
def dynamic_navbar():
navbar = Navbar(title='navbar_titel')
navbar.items = [View('FirstPage', 'first_page')]
navbar.items.append(
Subgroup('Dropdown1',
View('Sub1', 'sub1_page'),
View('Sub2', 'sub2_page'),
View('Sub3', 'sub3_page')
)
)
navbar.items.append(View('SecondPage', 'second_page'))
return navbar
nav.register_element('top', dynamic_navbar)
I also changed the default BootstrapRenderer bootloader, so I can easily change the navbar bootstrap template
class CustomRenderer(BootstrapRenderer):
def visit_Navbar(self, node):
nav_tag = super(CustomRenderer, self).visit_Navbar(node)
nav_tag['class'] += 'navbar navbar-inverse'
return nav_tag
register_renderer(app, 'custom', CustomRenderer)
All this works great, and I can easily integrate it into my template as a block:
{% extends "bootstrap/base.html" %}
{% block navbar %}
{{nav.top.render(renderer='custom')}}
{% endblock %}
{% block content %}{% endblock %}
So here is the last problem. I would like to align some, but not all, elements inside my navigator to the right and not to the left (for example: only View (Sub3 ...). I know how to do this directly in the HTML document, but somehow it’s hard to do an easy way this is in my Flask application without losing my dynamic navigator design or creating many new classes.
Renderer View ?