-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from level12/58-nav-features
Nav generation: add additional features
- Loading branch information
Showing
12 changed files
with
207 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,44 @@ | ||
{% macro render_node(nav_node) -%} | ||
{% macro render_link_text(node) %} | ||
{% if node.icon_class %}<i class="{{ node.icon_class }}"></i>{% endif %}{{ node.label | trim }} | ||
{% endmacro %} | ||
|
||
{% macro render_node(node, expand_to_current) -%} | ||
{# render a node (and its children, if appropriate) #} | ||
{% set NODE_LEAF = 1 %} | ||
<li> | ||
{% if nav_node.node_type == NODE_LEAF %} | ||
<a href="{{ nav_node.route.url }}">{{ nav_node.label }}</a> | ||
{% else %} | ||
<a class="menu-header">{{ nav_node.label }}</a> | ||
<ul> | ||
{% for sub_node in nav_node.permitted_sub_nodes %} | ||
{{ render_node(sub_node) }} | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
|
||
{% if node.node_type == NODE_LEAF %} | ||
<li{% if node.has_current_route %} class="nav-current"{% endif %}> | ||
<a href="{{ node.route.url }}">{{ render_link_text(node) }}</a> | ||
</li> | ||
{% elif node.sub_nodes %} | ||
<li>{{ render_group(node, expand_to_current) }}</li> | ||
{% else %} | ||
<li><a class="menu-header">{{ render_link_text(node) }}</a></li> | ||
{% endif %} | ||
{%- endmacro %} | ||
|
||
{% macro render_menu(nav_node) -%} | ||
{% for sub_node in nav_node.permitted_sub_nodes %} | ||
{{ render_node(sub_node) }} | ||
{% macro render_group(node, expand_to_current) %} | ||
<a class="menu-header group-header" data-toggle="collapse" href="#navgroup-{{ node.nav_group }}" | ||
{% if expand_to_current and node.has_current_route %}aria-expanded="true"{% endif %}> | ||
{{ render_link_text(node) }} | ||
<b class="caret"></b> | ||
</a> | ||
<div class="collapse {% if expand_to_current and node.has_current_route %}in{% endif %}" | ||
id="navgroup-{{ node.nav_group }}"> | ||
<ul> | ||
{% for sub_node in node.permitted_sub_nodes %} | ||
{{ render_node(sub_node, expand_to_current) }} | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% endmacro %} | ||
|
||
{% macro render_menu(node, expand_to_current=False) -%} | ||
{% for sub_node in node.permitted_sub_nodes %} | ||
{{ render_node(sub_node, expand_to_current) }} | ||
{% endfor %} | ||
{%- endmacro %} | ||
|
||
{% if auth_manager is defined %} | ||
{{ render_menu(auth_manager.menus['main']) }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters