2 Render a navbar-nav element. menu must be a MenuItems object
7 @author Robert Down <robertdown@live.com>
8 @copyright Copyright (c) 2023 Robert Down
9 @copyright Copyright (c) 2023 Providence Healthtech
12 {% macro navbar_nav(menu, container = "ul", listElement = "li") %}
13 {% import "html/macros/attribute_list.twig" as html %}
14 {% set _containerClasses = ['navbar-nav', 'mr-auto'] %}
15 <{{ container }} class="{{ _containerClasses|join(' ') }}">
16 {% for item in menu %}
17 {% set _preText = (item.getPreTextContent()) ? item.getPreTextContent() ~ " " : "" %}
18 {% set _postText = (item.getPostTextContent()) ? " " ~ item.getPostTextContent() : "" %}
19 {% set _listClassList = ["nav-item"]|merge(item.getLinkContainerClassList())|join(' ')|attr %}
20 {% set _aClassList = ["nav-link"]|merge(item.getLinkClassList())|join(' ')|attr %}
21 {% set excludesList = ["href", "class", "id"] %}
22 <{{ listElement }} class="{{ _listClassList }}">
23 <a href="{{ item.getId()|attr }}" class="{{ _aClassList }}" {{ html.attributeList(item.getAttributes(), excludesList) }}>{{ _preText|xlt }}{{ item.getDisplayText()|xlt }}{{ _postText|xlt }}</a>