Registers a renderer on the application.
- Parameters:
app – The
Flaskapplication to register the renderer oniid – Internal id-string for the renderer
renderer – Renderer to register
force – Whether or not to overwrite the renderer if a different one is already registered for
iid
Retrieve a renderer.
- Parameters:
app –
Flaskapplication to lookiidup oniid – Internal renderer id-string to look up
Bases:
ExceptionThe NavbarRenderingError class.
Bases:
MutableMappingThe ElementRegistry class.
Bases:
objectThe Flask-Nav extension.
- Parameters:
app – An optional
Flaskapp to initialize.
Initialize an application.
- Parameters:
app – A
Flaskapp.
Function decorator for navbar registration.
Convenience function, calls
register_element()withiidand the decorated function aselem.- Parameters:
iid – ID to pass on. If
None, uses the decorated functions name.
Register navigational element.
Registers the given navigational element, making it available using the id
iid.This means that inside any template, the registered element will be available as
nav.id.If
elemis callable, any attempt to retrieve it inside the template will instead result inelembeing called and the result being returned.- Parameters:
iid – Id to register element with
elem – Element to register
Class decorator for Renderers.
The decorated class will be added to the list of renderers kept by this instance that will be registered on the app upon app initialization.
- Parameters:
iid – Id for the renderer, defaults to the class name in snake case.
force – Whether or not to overwrite existing renderers.
Bases:
objectBase for all items in a Navigation.
Every item inside a navigational view should derive from this class.
Indicates whether or not the item represents the currently active route
Render the navigational item using a renderer.
- Parameters:
renderer – An object implementing the
Rendererinterface.- Returns:
A markupsafe string with the rendered result.
Bases:
NavigationItemAn item that contains a link to a destination and a title.
Returns the URL to the destination.
Bases:
NavigationItemAn item usually expressed by a single HTML tag.
- Parameters:
title – The text inside the tag.
attribs – Attributes on the item.
Bases:
LinkApplication-internal link.
The
endpoint,*argsand**kwargsare passed on tourl_for()to get the link.- Parameters:
text – The text for the link.
endpoint – The name of the view.
kwargs – Extra keyword arguments for
url_for()
By default, query arguments are ignored.”””
Return url for this item.
- Returns:
A string with a link.
Return True it view is active.
Bases:
NavigationItemSeparator.
A seperator inside the main navigational menu or a Subgroup. Not all renderers render these (or sometimes only inside Subgroups).
Bases:
NavigationItemNested substructure.
Usually used to express a submenu.
- Parameters:
title – The title to display (i.e. when using dropdown-menus, this text will be on the button).
items – Any number of
NavigationIteminstances that make up the navigation element.
Return True if any element is currently active.
Bases:
NavigationItemLabel text.
Not a
<label>text, but a text label nonetheless. Precise representation is up to the renderer, but most likely something like<span>,<div>or similar.
Bases:
SubgroupTop level navbar.
Bases:
VisitorBase interface for navigation renderers.
Visiting a node should return a string or an object that converts to a string containing HTML.
Fallback rendering for objects.
If the current application is in debug-mode (
flask.current_app.debugisTrue), an<!-- HTML comment -->will be rendered, indicating which class is missing a visitation function.Outside of debug-mode, returns an empty string.
Bases:
RendererA very basic HTML5 renderer.
Renders a navigational structure using
<nav>and<ul>tags that can be styled using modern CSS.- Parameters:
kwargs – Additional attributes to pass on to the root
<nav>-tag.
Returns arefs matching url.
Returns navbar classes.
Returns arefs.
Returns subgroup divs.
Returns separator hrs.
Returns nav-label spans.
Bases:
RendererA very basic Bootstrap 5 renderer.
Renders a navigational structure using
<nav>and<ul>tags that can be styled using modern CSS.- Parameters:
kwargs – Additional attributes to pass on to the root
<nav>-tag.
Returns arefs matching url.
Returns navbar classes.
Returns arefs.
Returns subgroup divs.
Returns separator hrs.
Returns nav-label spans.