diff --git a/core/includes/theme.inc b/core/includes/theme.inc index d811f4d..2d4c361 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1022,7 +1022,7 @@ function template_preprocess_links(&$variables) { $variables['links'] = array(); foreach ($links as $key => $link) { - $item = array(); + $item = array('key' => $key); $link += array( 'href' => NULL, 'route_name' => NULL, @@ -1030,10 +1030,6 @@ function template_preprocess_links(&$variables) { 'ajax' => NULL, ); - $li_attributes = array('class' => array()); - // Use the array key as class name. - $li_attributes['class'][] = drupal_html_class($key); - $keys = array('title', 'href', 'route_name', 'route_parameters'); $link_element = array( '#type' => 'link', @@ -1047,6 +1043,7 @@ function template_preprocess_links(&$variables) { // Handle links and ensure that the active class is added on the LIs, but // only if the 'set_active_class' option is not empty. + $li_attributes = array(); if (isset($link['href']) || isset($link['route_name'])) { if (!empty($variables['set_active_class'])) { diff --git a/core/modules/system/templates/links.html.twig b/core/modules/system/templates/links.html.twig index 3823c22..06cb8f1 100644 --- a/core/modules/system/templates/links.html.twig +++ b/core/modules/system/templates/links.html.twig @@ -15,6 +15,7 @@ * not be passed through \Drupal\Component\Utility\String::checkPlain(). * - attributes: (optional) HTML attributes for the anchor, or for the * tag if no 'href' is supplied. + * - key: The link key. To be used as link class. * - heading: (optional) A heading to precede the links. * - text: The heading text. * - level: The heading level (e.g. 'h2', 'h3'). @@ -45,7 +46,7 @@ {%- endif -%} {%- for item in links -%} - + {%- if item.link -%} {{ item.link }} {%- elseif item.text_attributes -%}