<ul>
{% for menuItem in menu|sort((a, b) => a.priority <=> b.priority) %}
{% set isActive = menuItem.page and menuItem.page.lft <= page.lft and page.rgt <= menuItem.page.rgt %}
{% if menuItem.isActive %}
<li>
<a href="{{ menuItem.toUrl() ? menuItem.toUrl() : 'javascript:void(0);' }}"
class="{{ isActive ? 'active' }}">{{ menuItem.name }}</a>
</li>
{% endif %}
{% endfor %}
</ul>