summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-08-12 07:29:39 (GMT)
committerAlex Pott2014-08-12 07:29:39 (GMT)
commitad64eddb50df1a3b2839bb19ab16960fc40c9fc2 (patch)
treeca1f7d524907e942e231ab2925fd360dcc656b93
parent3f3fc8db8ff8c498e45c8ab4f874be0ec84be7ec (diff)
Issue #2260059 by er.pushpinderrana, joelpittet, LinL, SebCorbin | Mark Carver: Fixed Title in template_preprocess_item_list() is typecasted as string.
-rw-r--r--core/includes/theme.inc2
-rw-r--r--core/modules/system/src/Tests/Theme/FunctionsTest.php17
-rw-r--r--core/modules/system/templates/item-list.html.twig2
3 files changed, 18 insertions, 3 deletions
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 @@ class FunctionsTest extends WebTestBase {
$expected = '<div class="item-list"><h3>Some title</h3>No items found.</div>';
$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 = '<div class="item-list"><h3>0</h3>No items found.</div>';
+ $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' => '<span>Render array</span>',
+ );
+ $variables['empty'] = 'No items found.';
+ $expected = '<div class="item-list"><h3><span>Render array</span></h3>No items found.</div>';
+ $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 -%}
<div class="item-list">
- {%- if title -%}
+ {%- if title is not empty -%}
<h3>{{ title }}</h3>
{%- endif -%}
{%- if items -%}