From 9e47f0c7cb5a0d066dc1d8b3045e47fff724d170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Tue, 1 Jan 2019 11:04:46 -0500 Subject: [PATCH] Take bloody two in adding a class without it hanging around --- agaric/templates/navigation/menu.html.twig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/agaric/templates/navigation/menu.html.twig b/agaric/templates/navigation/menu.html.twig index 249a4a7..1cd37b5 100644 --- a/agaric/templates/navigation/menu.html.twig +++ b/agaric/templates/navigation/menu.html.twig @@ -33,7 +33,7 @@ {{ menus.menu_links(items, attributes, 0, menu_name) }} {% macro menu_links(items, attributes, menu_level, menu_name) %} {% set submenu_attributes = create_attribute() %} - {% set link_attributes = create_attribute().addClass('navbar-item') %} + {% set link_attributes = create_attribute() %} {% import _self as menus %} {% set submenu_classes = [ 'navbar-item', @@ -45,10 +45,14 @@ {% endif %} {% for item in items %} - {{ link(item.title, item.url, link_attributes) }} - {% if item.below %} - {{ menus.menu_links(item.below, attributes, menu_level + 1) }} - {% endif %} + {% set link_classes = ['navbar-item'] %} + {% if item.in_active_trail %} + {% set link_classes = link_classes|merge(['is-active']) %} + {% endif %} + {{ link(item.title, item.url, link_attributes.addClass(link_classes)) }} + {% if item.below %} + {{ menus.menu_links(item.below, attributes, menu_level + 1) }} + {% endif %} {% endfor %} {% endif %} {% endmacro %}