summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Rowlands2018-05-14 20:46:40 (GMT)
committerLee Rowlands2018-05-14 20:46:40 (GMT)
commit251c996272ec9a9ce1ff5d632f1a014f99b16676 (patch)
treeed7b7dc7576c41ee95eda3fc5a4ff4b98d1e8491
parenta085bc61dc7cfbc97bbc731eeddc71760fdb7e13 (diff)
Issue #2789909 by vaplas, Lendude, lucur, dawehner: Remove spaces around row.content
-rw-r--r--core/modules/views/templates/views-view-grid.html.twig4
-rw-r--r--core/modules/views/templates/views-view-list.html.twig4
-rw-r--r--core/modules/views/templates/views-view-unformatted.html.twig2
-rw-r--r--core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc5
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php38
-rw-r--r--core/themes/classy/templates/views/views-view-grid.html.twig4
-rw-r--r--core/themes/classy/templates/views/views-view-list.html.twig4
-rw-r--r--core/themes/classy/templates/views/views-view-unformatted.html.twig2
-rw-r--r--core/themes/stable/templates/views/views-view-grid.html.twig4
-rw-r--r--core/themes/stable/templates/views/views-view-list.html.twig4
-rw-r--r--core/themes/stable/templates/views/views-view-unformatted.html.twig2
11 files changed, 60 insertions, 13 deletions
diff --git a/core/modules/views/templates/views-view-grid.html.twig b/core/modules/views/templates/views-view-grid.html.twig
index f2b1552..b1aab93 100644
--- a/core/modules/views/templates/views-view-grid.html.twig
+++ b/core/modules/views/templates/views-view-grid.html.twig
@@ -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>
diff --git a/core/modules/views/templates/views-view-list.html.twig b/core/modules/views/templates/views-view-list.html.twig
index 8de787c..558b31a 100644
--- a/core/modules/views/templates/views-view-list.html.twig
+++ b/core/modules/views/templates/views-view-list.html.twig
@@ -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 }}>
diff --git a/core/modules/views/templates/views-view-unformatted.html.twig b/core/modules/views/templates/views-view-unformatted.html.twig
index 7ee1f81..b67b5f7 100644
--- a/core/modules/views/templates/views-view-unformatted.html.twig
+++ b/core/modules/views/templates/views-view-unformatted.html.twig
@@ -27,6 +27,6 @@
]
%}
<div{{ row.attributes.addClass(row_classes) }}>
- {{ row.content }}
+ {{- row.content -}}
</div>
{% endfor %}
diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
index dd69f4c..8eaa704 100644
--- a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
+++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
@@ -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'][] = [];
+ }
+ }
}
/**
diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
index e420ea7..3904cdb 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
@@ -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 @@ class DisplayPageTest extends ViewsKernelTestBase {
$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'.");
+ }
+ }
+ }
+
}
diff --git a/core/themes/classy/templates/views/views-view-grid.html.twig b/core/themes/classy/templates/views/views-view-grid.html.twig
index 2fe3028..8a3a20b 100644
--- a/core/themes/classy/templates/views/views-view-grid.html.twig
+++ b/core/themes/classy/templates/views/views-view-grid.html.twig
@@ -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>
diff --git a/core/themes/classy/templates/views/views-view-list.html.twig b/core/themes/classy/templates/views/views-view-list.html.twig
index 44d4766..50cc74b 100644
--- a/core/themes/classy/templates/views/views-view-list.html.twig
+++ b/core/themes/classy/templates/views/views-view-list.html.twig
@@ -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 }}>
diff --git a/core/themes/classy/templates/views/views-view-unformatted.html.twig b/core/themes/classy/templates/views/views-view-unformatted.html.twig
index bece528..534ac9a 100644
--- a/core/themes/classy/templates/views/views-view-unformatted.html.twig
+++ b/core/themes/classy/templates/views/views-view-unformatted.html.twig
@@ -25,6 +25,6 @@
]
%}
<div{{ row.attributes.addClass(row_classes) }}>
- {{ row.content }}
+ {{- row.content -}}
</div>
{% endfor %}
diff --git a/core/themes/stable/templates/views/views-view-grid.html.twig b/core/themes/stable/templates/views/views-view-grid.html.twig
index 2fe3028..8a3a20b 100644
--- a/core/themes/stable/templates/views/views-view-grid.html.twig
+++ b/core/themes/stable/templates/views/views-view-grid.html.twig
@@ -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>
diff --git a/core/themes/stable/templates/views/views-view-list.html.twig b/core/themes/stable/templates/views/views-view-list.html.twig
index 44d4766..50cc74b 100644
--- a/core/themes/stable/templates/views/views-view-list.html.twig
+++ b/core/themes/stable/templates/views/views-view-list.html.twig
@@ -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 }}>
diff --git a/core/themes/stable/templates/views/views-view-unformatted.html.twig b/core/themes/stable/templates/views/views-view-unformatted.html.twig
index bece528..534ac9a 100644
--- a/core/themes/stable/templates/views/views-view-unformatted.html.twig
+++ b/core/themes/stable/templates/views/views-view-unformatted.html.twig
@@ -25,6 +25,6 @@
]
%}
<div{{ row.attributes.addClass(row_classes) }}>
- {{ row.content }}
+ {{- row.content -}}
</div>
{% endfor %}