This project is not covered by Drupal’s security advisory policy.

Simple twig filter to add attributes to link() item.url's in templates.

Has the advantage of merging attributes so modules like Menu Link Attributes do not have their attributes blown away in the template.

For example, current documentation encourages themers to do this:

{{ link(item.title, item.url, { 'class':['menu__link']}) }}

However classes added via preprocess or Menu Link Attributes will no longer be applied, as the above code blows them away.

Usage:

Filter: link_attributes('attribute type':[attribute values])

E.g. in menu.html.twig you can do stuff like this:

{{ link(item.title, item.url|link_attributes({'class' : ['menu__link'], 'data-drupal-example' : ['is-item']})) }}

Supporting organizations: 
Development

Project information

Releases