diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 8d985b3..f7acb39 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1755,8 +1755,6 @@ function template_preprocess_tablesort_indicator(&$variables) { * @see http://drupal.org/node/1842756 */ function template_preprocess_item_list(&$variables) { - $variables['title'] = (string) $variables['title']; - foreach ($variables['items'] as &$item) { $attributes = array(); // If the item value is an array, then it is a render array. diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index f6eaa6c..577e075 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -55,6 +55,23 @@ function testItemList() { $expected = '

Some title

No items found.
'; $this->assertThemeOutput('item_list', $variables, $expected, 'Empty %callback generates empty string with title.'); + // Verify that title set to 0 is output. + $variables = array(); + $variables['title'] = 0; + $variables['empty'] = 'No items found.'; + $expected = '

0

No items found.
'; + $this->assertThemeOutput('item_list', $variables, $expected, '%callback with title set to 0 generates a title.'); + + // Verify that title set to a render array is output. + $variables = array(); + $variables['title'] = array( + '#theme' => 'markup', + '#markup' => 'Render array', + ); + $variables['empty'] = 'No items found.'; + $expected = '

Render array

No items found.
'; + $this->assertThemeOutput('item_list', $variables, $expected, '%callback with title set to a render array generates a title.'); + // Verify that empty text is not displayed when there are list items. $variables = array(); $variables['title'] = 'Some title'; diff --git a/core/modules/system/templates/item-list.html.twig b/core/modules/system/templates/item-list.html.twig index 34e1802..bd71e7f 100644 --- a/core/modules/system/templates/item-list.html.twig +++ b/core/modules/system/templates/item-list.html.twig @@ -20,7 +20,7 @@ #} {%- if items or empty -%}
- {%- if title -%} + {%- if title is not empty -%}

{{ title }}

{%- endif -%} {%- if items -%}