Issue #2260059 by er.pushpinderrana, joelpittet, LinL, SebCorbin | Mark Carver: Fixed Title in template_preprocess_item_list() is typecasted as string.
parent
3f3fc8db8f
commit
ad64eddb50
|
@ -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.
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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 -%}
|
||||
|
|
Loading…
Reference in New Issue