Adding dividers between list items in the menu.html.twig template How do I add dividers between each &lt;li&gt; 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 %}
    &lt;ul class="loginbar pull-right"&gt;
    {% 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',
        ]
      %}
      &lt;li{{ item.attributes.addClass(classes) }}&gt;
        {{ link(item.title, item.url) }}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
        {% endif %}
      &lt;/li&gt;
      &lt;li class="topbar-devider"&gt;&lt;/li&gt;
    {% endfor %}
    &lt;/ul&gt;
  {% endif %}
{% endmacro %}
See The Loop Variable in the Twig docs; you can use something like

{% if loop.last == false %}
  &lt;li class="topbar-devider"&gt;&lt;/li&gt;
{% endif %}