Skip to content
Snippets Groups Projects
Commit 982ca4b5 authored by catch's avatar catch
Browse files

Issue #2154005 by olli: Views UI does not render preview for feeds.

parent ae12caf9
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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;
}
/**
......
......@@ -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.');
}
/**
......
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