Issue #2260059 by er.pushpinderrana, joelpittet, LinL, SebCorbin | Mark Carver: Fixed Title in template_preprocess_item_list() is typecasted as string.

8.0.x
Alex Pott 2014-08-12 00:29:39 -07:00
parent 3f3fc8db8f
commit ad64eddb50
3 changed files with 18 additions and 3 deletions

View File

@ -1755,8 +1755,6 @@ function template_preprocess_tablesort_indicator(&$variables) {
* @see http://drupal.org/node/1842756 * @see http://drupal.org/node/1842756
*/ */
function template_preprocess_item_list(&$variables) { function template_preprocess_item_list(&$variables) {
$variables['title'] = (string) $variables['title'];
foreach ($variables['items'] as &$item) { foreach ($variables['items'] as &$item) {
$attributes = array(); $attributes = array();
// If the item value is an array, then it is a render array. // If the item value is an array, then it is a render array.

View File

@ -55,6 +55,23 @@ class FunctionsTest extends WebTestBase {
$expected = '<div class="item-list"><h3>Some title</h3>No items found.</div>'; $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.'); $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. // Verify that empty text is not displayed when there are list items.
$variables = array(); $variables = array();
$variables['title'] = 'Some title'; $variables['title'] = 'Some title';

View File

@ -20,7 +20,7 @@
#} #}
{%- if items or empty -%} {%- if items or empty -%}
<div class="item-list"> <div class="item-list">
{%- if title -%} {%- if title is not empty -%}
<h3>{{ title }}</h3> <h3>{{ title }}</h3>
{%- endif -%} {%- endif -%}
{%- if items -%} {%- if items -%}