diff --git a/core/includes/theme.inc b/core/includes/theme.inc index b3deb32..a7b5eef 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -999,6 +999,7 @@ function template_preprocess_tablesort_indicator(&$variables) { * @see https://www.drupal.org/node/1842756 */ function template_preprocess_item_list(&$variables) { + $variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']); foreach ($variables['items'] as &$item) { $attributes = array(); // If the item value is an array, then it is a render array. @@ -1718,7 +1719,7 @@ function drupal_common_theme() { 'variables' => array('status' => MARK_NEW), ), 'item_list' => array( - 'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL, 'context' => array()), + 'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => array(), 'attributes' => array(), 'empty' => NULL, 'context' => array()), ), 'feed_icon' => array( 'variables' => array('url' => NULL, 'title' => NULL), diff --git a/core/modules/system/templates/item-list.html.twig b/core/modules/system/templates/item-list.html.twig index 172799d..1462cf4 100644 --- a/core/modules/system/templates/item-list.html.twig +++ b/core/modules/system/templates/item-list.html.twig @@ -9,6 +9,7 @@ * - value: The content of the list element. * - title: The title of the list. * - list_type: The tag for list element ("ul" or "ol"). + * - wrapper_attributes: HTML attributes to be applied to the list wrapper. * - attributes: HTML attributes to be applied to the list. * - empty: A message to display when there are no items. Allowed value is a * string or render array. @@ -21,9 +22,9 @@ */ #} {% if context.list_style %} - {% set attributes = attributes.addClass('item-list__' ~ context.list_style) %} + {%- set attributes = attributes.addClass('item-list__' ~ context.list_style) %} {% endif %} -{%- if items or empty -%} +{% if items or empty %} {%- if title is not empty -%}

{{ title }}

{%- endif -%} diff --git a/core/themes/classy/css/dataset/item-list.css b/core/themes/classy/css/dataset/item-list.css index bce0456..da51a40 100644 --- a/core/themes/classy/css/dataset/item-list.css +++ b/core/themes/classy/css/dataset/item-list.css @@ -16,7 +16,7 @@ [dir="rtl"] .item-list ul li { margin: 0 1.5em 0.25em 0; } -div.item-list__comma-list { +.item-list--comma-list { display: inline; } /** diff --git a/core/themes/classy/templates/dataset/item-list.html.twig b/core/themes/classy/templates/dataset/item-list.html.twig index abecd47..20541b0 100644 --- a/core/themes/classy/templates/dataset/item-list.html.twig +++ b/core/themes/classy/templates/dataset/item-list.html.twig @@ -9,6 +9,7 @@ * - value: The content of the list element. * - title: The title of the list. * - list_type: The tag for list element ("ul" or "ol"). + * - wrapper_attributes: HTML attributes to be applied to the list wrapper. * - attributes: HTML attributes to be applied to the list. * - empty: A message to display when there are no items. Allowed value is a * string or render array. @@ -18,14 +19,12 @@ * @see template_preprocess_item_list() */ #} -{%- if context.list_style -%} - {%- set attributes = attributes.addClass('item-list__' ~ context.list_style) -%} - {%- set wrapper_class = 'item-list item-list__' ~ context.list_style -%} -{%- else -%} - {%- set wrapper_class = 'item-list' -%} -{%- endif -%} -{%- if items or empty -%} -
+{% if context.list_style %} + {%- set wrapper_attributes = wrapper_attributes.addClass('item-list--' ~ context.list_style) %} + {%- set attributes = attributes.addClass('item-list__' ~ context.list_style) %} +{% endif %} +{% if items or empty -%} + {%- if title is not empty -%}

{{ title }}

{%- endif -%}