{{ postEvent("Template.beforeTopBar", userAlias, userLogin, topMenu, userMenu) }}
<ul role="menubar" class="navbar-right">

    {% macro menuItemLabel(label, icon) %}
        {% if icon is defined and icon and icon starts with 'icon-' %}
            <span class="{{ icon|striptags }}" aria-label="{{ label|translate|e('html_attr') }}"></span>
        {% else %}
            {{ label|translate }}
        {% endif %}
    {% endmacro %}

    {% macro topMenuItem(label, menu, currentModule, currentAction) %}
        {% if menu._html is defined %}
            {{ menu._html|raw }}
        {% else %}
            <a {% if menu._tooltip is defined %}title="{{ menu._tooltip }}"{% endif %}
               class="topBarElem {% if (menu._url.module == currentModule and (menu._url.action is empty or menu._url.action == currentAction)) %}active{% endif %}"
               id="topmenu-{{ menu._url.module|lower }}"
               href="index.php{{ menu._url|urlRewriteWithParameters }}" tabindex="3">{{ _self.menuItemLabel(label, menu._icon) }}</a>
        {% endif %}
    {% endmacro %}

    {% if topMenuModule is not defined %}
        {% set topMenuModule = currentModule %}
        {% set topMenuAction = currentAction %}
    {% endif %}

    {% spaceless %}
        {% for label,menu in topMenu %}
            <li role="menuitem">{{ _self.topMenuItem(label, menu, topMenuModule, topMenuAction) }}</li>
        {% endfor %}
    {% endspaceless %}

</ul>