Problem/Motivation
Currently it is not possible to set attributes from a render array for the li element in links.html.twig.
Proposed resolution
Allow setting attributes for the li elements from render array.
Currently it is not possible to set attributes from a render array for the li element in links.html.twig.
Allow setting attributes for the li elements from render array.
Comments
Comment #11
avpadernoIs this still relevant? I am asking because in the Seven theme there is a note that links to this issue.
Comment #12
avpadernoTo make clearer what the issue summary says, the documentation for
template_preprocess_links()says:\Drupal\Core\Urlobject to link to. If the 'url' element is supplied, the 'title' and 'url' are used to generate a link through\Drupal::linkGenerator()->generate(). All data from the link array other than 'title' and 'url' are added as #options on the URL object. See\Drupal\Core\Url::fromUri()for details on the options. If no 'url' is supplied, the 'title' is printed as plain text.<span>tag used in its place if no 'url' is supplied. If element 'class' is included, it must be an array of one or more class names.The attributes are for the anchor, or for the
<span>tag used in its place, not for the<li>items.Comment #13
lauriiiExactly, the problem is that the attributes from that list get added to the
<a>element and not the<li>. There's a way to add attributes from preprocess but not from the render array that's constructing the list.