Successfully add link classes to active item ancestor, without hangover
Unlike 9e47f0c7cb
where i was just trying to avoid creating the link_attributes
object for every item. That was not to be.
This commit is contained in:
parent
9e47f0c7cb
commit
ef5f877a60
1 changed files with 3 additions and 4 deletions
|
@ -33,7 +33,6 @@
|
||||||
{{ menus.menu_links(items, attributes, 0, menu_name) }}
|
{{ menus.menu_links(items, attributes, 0, menu_name) }}
|
||||||
{% macro menu_links(items, attributes, menu_level, menu_name) %}
|
{% macro menu_links(items, attributes, menu_level, menu_name) %}
|
||||||
{% set submenu_attributes = create_attribute() %}
|
{% set submenu_attributes = create_attribute() %}
|
||||||
{% set link_attributes = create_attribute() %}
|
|
||||||
{% import _self as menus %}
|
{% import _self as menus %}
|
||||||
{% set submenu_classes = [
|
{% set submenu_classes = [
|
||||||
'navbar-item',
|
'navbar-item',
|
||||||
|
@ -45,11 +44,11 @@
|
||||||
<div{{ submenu_attributes.addClass(submenu_classes) }}>
|
<div{{ submenu_attributes.addClass(submenu_classes) }}>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
{% set link_classes = ['navbar-item'] %}
|
{% set link_attributes = create_attribute().addClass('navbar-item') %}
|
||||||
{% if item.in_active_trail %}
|
{% if item.in_active_trail %}
|
||||||
{% set link_classes = link_classes|merge(['is-active']) %}
|
{% set link_attributes = link_attributes.addClass('is-active') %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ link(item.title, item.url, link_attributes.addClass(link_classes)) }}
|
{{ link(item.title, item.url, link_attributes) }}
|
||||||
{% if item.below %}
|
{% if item.below %}
|
||||||
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
|
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue