Skip to content
Snippets Groups Projects
Verified Commit 251c9962 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2789909 by vaplas, Lendude, lucur, dawehner: Remove spaces around row.content

parent a085bc61
No related branches found
No related tags found
No related merge requests found
Showing
with 60 additions and 13 deletions
......@@ -59,7 +59,7 @@
<div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
{% for column in row.content %}
<div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
{{ column.content }}
{{- column.content -}}
</div>
{% endfor %}
</div>
......@@ -69,7 +69,7 @@
<div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
{% for row in column.content %}
<div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
{{ row.content }}
{{- row.content -}}
</div>
{% endfor %}
</div>
......
......@@ -28,7 +28,9 @@
<{{ list.type }}{{ list.attributes }}>
{% for row in rows %}
<li{{ row.attributes }}>{{ row.content }}</li>
<li{{ row.attributes }}>
{{- row.content -}}
</li>
{% endfor %}
</{{ list.type }}>
......
......@@ -27,6 +27,6 @@
]
%}
<div{{ row.attributes.addClass(row_classes) }}>
{{ row.content }}
{{- row.content -}}
</div>
{% endfor %}
......@@ -74,6 +74,11 @@ function views_test_data_placeholders() {
*/
function views_test_data_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
\Drupal::state()->set('views_hook_test_views_post_render', TRUE);
if ($view->storage->id() === 'test_page_display' && $view->current_display === 'empty_row') {
for ($i = 0; $i < 5; $i++) {
$output['#rows'][0]['#rows'][] = [];
}
}
}
/**
......
......@@ -30,7 +30,7 @@ class DisplayPageTest extends ViewsKernelTestBase {
*
* @var array
*/
public static $modules = ['system', 'user', 'field'];
public static $modules = ['system', 'user', 'field', 'views_test_data'];
/**
* The router dumper to get all routes.
......@@ -220,4 +220,40 @@ public function testReadMore() {
$this->assertTrue($view->getDisplay()->getOption('use_more_always'), 'Always display the more link by default.');
}
/**
* Tests the templates with empty rows.
*/
public function testEmptyRow() {
$view = Views::getView('test_page_display');
$view->initDisplay();
$view->newDisplay('page', 'Page', 'empty_row');
$view->save();
$styles = [
'default' => '//div[@class="views-row"]',
'grid' => '//div[contains(@class, "views-col")]',
'html_list' => '//div[@class="item-list"]//li',
];
$themes = ['bartik', 'classy', 'seven', 'stable', 'stark'];
foreach ($themes as $theme) {
\Drupal::service('theme_handler')->install([$theme]);
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme($theme));
foreach ($styles as $type => $xpath) {
$view = Views::getView('test_page_display');
$view->storage->invalidateCaches();
$view->initDisplay();
$view->setDisplay('empty_row');
$view->displayHandlers->get('empty_row')->default_display->options['style']['type'] = $type;
$view->initStyle();
$this->executeView($view);
$output = $view->preview();
$output = \Drupal::service('renderer')->renderRoot($output);
$this->setRawContent($output);
$this->assertCount(5, $this->xpath("{$xpath}[not(text()) and not(node())]"), "Empty rows in theme '$theme', type '$type'.");
}
}
}
}
......@@ -57,7 +57,7 @@
<div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
{% for column in row.content %}
<div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
{{ column.content }}
{{- column.content -}}
</div>
{% endfor %}
</div>
......@@ -67,7 +67,7 @@
<div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
{% for row in column.content %}
<div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
{{ row.content }}
{{- row.content -}}
</div>
{% endfor %}
</div>
......
......@@ -26,7 +26,9 @@
<{{ list.type }}{{ list.attributes }}>
{% for row in rows %}
<li{{ row.attributes }}>{{ row.content }}</li>
<li{{ row.attributes }}>
{{- row.content -}}
</li>
{% endfor %}
</{{ list.type }}>
......
......@@ -25,6 +25,6 @@
]
%}
<div{{ row.attributes.addClass(row_classes) }}>
{{ row.content }}
{{- row.content -}}
</div>
{% endfor %}
......@@ -57,7 +57,7 @@
<div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
{% for column in row.content %}
<div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
{{ column.content }}
{{- column.content -}}
</div>
{% endfor %}
</div>
......@@ -67,7 +67,7 @@
<div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
{% for row in column.content %}
<div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
{{ row.content }}
{{- row.content -}}
</div>
{% endfor %}
</div>
......
......@@ -26,7 +26,9 @@
<{{ list.type }}{{ list.attributes }}>
{% for row in rows %}
<li{{ row.attributes }}>{{ row.content }}</li>
<li{{ row.attributes }}>
{{- row.content -}}
</li>
{% endfor %}
</{{ list.type }}>
......
......@@ -25,6 +25,6 @@
]
%}
<div{{ row.attributes.addClass(row_classes) }}>
{{ row.content }}
{{- row.content -}}
</div>
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment