{# This macro is called on the user dashboards. In this case the administrator dashboard
at the route admin.index
#}
{% macro render_menu_items(endpoints) %}
{%- for endpoint, name, icon in endpoints %}
{%- if icon %}
{%- endif %}
{{ name | safe }}
{%- endfor %}
{% endmacro %}
{# This is called for all users (including anonymous users). It renders the basic left side of the
navigation bar. In the default case, the left hand side will read 'Flask-Base'. In the logged in
admin case, there will also be an item that links to admin/ route. I have added an example use of
render_menu_items.
#}
{% macro header_items(current_user) %}
{%- set endpoints = [
('main.index', "Home", 'home'),
('apps.index', 'Apps', 'add'),
('templates.index', 'Templates', 'list')
]%}
{%- set user = [] %}
{%- if current_user.is_authenticated %}
{% set user = ([(current_user.role.index + '.index', 'User
Dashboard', 'user')]) %}
{%- endif %}
{{ render_menu_items( endpoints + user ) }}
{% endmacro %}
{# This renders the right hand side of the navigation bar. If the user is logged in, it links to
manage their account and logout (account routes). Otherwise, it links to register and login.
#}
{% macro account_items(current_user) %}
{% if current_user.is_authenticated %}
{% set endpoints = [
('account.manage', 'Account
Settings', 'settings'),
('account.logout', 'Log out', 'sign out')
] %}
{{ render_menu_items(endpoints) }}
{% else %}
{% set endpoints = [
('account.register', 'Register', 'list layout'),
('account.login', 'Log In', 'sign in')
] %}
{{ render_menu_items(endpoints) }}
{% endif %}
{% endmacro %}
{% macro mobile_nav(current_user, dropdown=None) %}