mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
NEW Disable shortcodes in $Layout and $Content in SSViewer
This commit is contained in:
parent
cd41a536b9
commit
d2650bbc44
@ -898,6 +898,41 @@ after')
|
||||
);
|
||||
}
|
||||
|
||||
protected function useTestTheme($theme, $callback) {
|
||||
global $project;
|
||||
|
||||
$themeBaseDir = dirname(__FILE__);
|
||||
$manifest = new SS_TemplateManifest($themeBaseDir, $project, true, true);
|
||||
|
||||
SS_TemplateLoader::instance()->pushManifest($manifest);
|
||||
|
||||
$origTheme = SSViewer::current_theme();
|
||||
SSViewer::set_theme($theme);
|
||||
|
||||
$e = null;
|
||||
|
||||
try { $callback(); }
|
||||
catch (Exception $e) { /* NOP for now, just save $e */ }
|
||||
|
||||
// Remove all the test themes we created
|
||||
SS_TemplateLoader::instance()->popManifest();
|
||||
SSViewer::set_theme($origTheme);
|
||||
|
||||
if ($e) throw $e;
|
||||
}
|
||||
|
||||
public function testLayout() {
|
||||
$self = $this;
|
||||
|
||||
$this->useTestTheme('layouttest', function() use ($self) {
|
||||
$template = new SSViewer(array('Page'));
|
||||
$self->assertEquals('Foo', $template->process(new ArrayData(array())));
|
||||
|
||||
$template = new SSViewer(array('Shortcodes', 'Page'));
|
||||
$self->assertEquals('[file_link]', $template->process(new ArrayData(array())));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SSViewer::get_themes()
|
||||
*/
|
||||
@ -929,7 +964,7 @@ after')
|
||||
// Remove all the test themes we created
|
||||
Filesystem::removeFolder($testThemeBaseDir);
|
||||
}
|
||||
|
||||
|
||||
public function testRewriteHashlinks() {
|
||||
$oldRewriteHashLinks = SSViewer::getOption('rewriteHashlinks');
|
||||
SSViewer::setOption('rewriteHashlinks', true);
|
||||
|
1
tests/view/themes/layouttest/Layout/Page.ss
Normal file
1
tests/view/themes/layouttest/Layout/Page.ss
Normal file
@ -0,0 +1 @@
|
||||
Foo
|
1
tests/view/themes/layouttest/Layout/Shortcodes.ss
Normal file
1
tests/view/themes/layouttest/Layout/Shortcodes.ss
Normal file
@ -0,0 +1 @@
|
||||
[file_link]
|
1
tests/view/themes/layouttest/Page.ss
Normal file
1
tests/view/themes/layouttest/Page.ss
Normal file
@ -0,0 +1 @@
|
||||
$Layout
|
@ -909,7 +909,12 @@ class SSViewer {
|
||||
$subtemplateViewer->includeRequirements(false);
|
||||
$subtemplateViewer->setPartialCacheStore($this->getPartialCacheStore());
|
||||
|
||||
$underlay[$subtemplate] = $subtemplateViewer->process($item, $arguments);
|
||||
$underlay[$subtemplate] = DBField::create_field(
|
||||
'HTMLText',
|
||||
$subtemplateViewer->process($item, $arguments),
|
||||
$subtemplate,
|
||||
array('shortcodes' => false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user