Trying to theme a menu in Drupal 8, running into a case where we need to add classes on certain links.
In the case of a menu link that is route:<nolink> we need to not add any class at all.
Example:
{% if item.below and item.url %} {{ link(item.title, item.url, { 'class':['link', 'link--arrow']} ) }} {% else %} // not a link {% endif %}
How can we tell at this level that item.url is route:<nolink>?
Update:
Current solution so far, is there a better way?
{% if not item.url.isExternal() and item.url.getRouteName() is same as('<nolink>') %} {{ link(item.title, item.url) }} {% else %} {{ link(item.title, item.url, { 'class':['link', 'link--arrow']} ) }} {% endif %}