How do I add dividers between each <li>
in the menu.html.twig
template. Obviously with the code below, the divider also gets added after the last item, which isn't the desired result.
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
<ul class="loginbar pull-right">
{% for item in items %}
{%
set classes = [
item.is_expanded ? 'menu-item--expanded',
item.is_collapsed ? 'menu-item--collapsed',
item.in_active_trail ? 'menu-item--active-trail',
]
%}
<li{{ item.attributes.addClass(classes) }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
<li class="topbar-devider"></li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}