diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php index 7915204e8ad3ed0d7bdf06506a315b6cc5fe46e8..ddcc1fab1dcaf131abc99e4e6cd445e741d50b72 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\display; +use Drupal\Component\Utility\String; use Drupal\views\ViewExecutable; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -86,11 +87,17 @@ public function execute() { * Overrides \Drupal\views\Plugin\views\display\PathPluginBase::preview(). */ public function preview() { + $output = $this->view->render(); + if (!empty($this->view->live_preview)) { - return '<pre>' . check_plain($this->view->render()) . '</pre>'; + $output = array( + '#prefix' => '<pre>', + '#markup' => String::checkPlain($output), + '#suffix' => '</pre>', + ); } - return $this->view->render(); + return $output; } /** diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php index 7f134134c0c1457dc8c9574f559799d4d2f413c2..77cc434638f1b330884ea47890e20448747d0b71 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php @@ -77,6 +77,21 @@ function testPreviewUI() { $this->assertText('Test header text', 'Rendered header text found'); $this->assertText('Test footer text', 'Rendered footer text found.'); $this->assertText('Test empty text', 'Rendered empty text found.'); + + // Test feed preview. + $view = array(); + $view['label'] = $this->randomName(16); + $view['id'] = strtolower($this->randomName(16)); + $view['page[create]'] = 1; + $view['page[title]'] = $this->randomName(16); + $view['page[path]'] = $this->randomName(16); + $view['page[feed]'] = 1; + $view['page[feed_properties][path]'] = $this->randomName(16); + $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); + $this->clickLink(t('Feed')); + $this->drupalPostForm(NULL, array(), t('Update preview')); + $result = $this->xpath('//div[@id="views-live-preview"]/pre'); + $this->assertTrue(strpos($result[0], '<title>' . $view['page[title]'] . '</title>'), 'The Feed RSS preview was rendered.'); } /**