fix: Navbar dropdown items render
This commit is contained in:
parent
c30898d785
commit
71ff441c42
1 changed files with 39 additions and 14 deletions
|
|
@ -1,23 +1,48 @@
|
|||
{% macro render_item(item, submenu=False) %}
|
||||
{% macro render_item(item, submenu=False, parent=False) %}
|
||||
{% if item.child_items %}
|
||||
|
||||
{% if parent %}
|
||||
<li class="nav-item dropdown {% if submenu %} dropdown-submenu {% endif %}">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ item.label }}
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ item.label }}
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
{% for child in item.child_items %}
|
||||
{{ render_item(child, True) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ (item.url or '')|abs_url }}"
|
||||
{{ item.target or ''}}>
|
||||
{{ item.label }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown {% if submenu %} dropdown-submenu {% endif %}">
|
||||
<a class="dropdown-item dropdown-toggle" href="#" id="navbarDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ item.label }}
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
{% for child in item.child_items %}
|
||||
{{ render_item(child, True) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% if parent %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ (item.url or '')|abs_url }}"
|
||||
{{ item.target or ''}}>
|
||||
{{ item.label }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<a class="dropdown-item" href="{{ (item.url or '') | abs_url }}"
|
||||
{{ item.target or '' }}>
|
||||
{{ item.label }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
|
@ -25,7 +50,7 @@
|
|||
<ul class="navbar-nav mr-auto">
|
||||
{%- for item in top_bar_items -%}
|
||||
{% if not item.parent_label and not item.right -%}
|
||||
{{ render_item(item) }}
|
||||
{{ render_item(item, parent=True) }}
|
||||
{%- endif -%}
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
|
|
@ -33,7 +58,7 @@
|
|||
<ul class="navbar-nav ml-auto">
|
||||
{%- for item in top_bar_items -%}
|
||||
{% if not item.parent_label and item.right -%}
|
||||
{{ render_item(item) }}
|
||||
{{ render_item(item, parent=True) }}
|
||||
{%- endif -%}
|
||||
{%- endfor %}
|
||||
{% if not only_static %}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue