Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NEW Disable shortcodes in $Layout and $Content in SSViewer

  • Loading branch information...
commit d2650bbc44b88665ffe16a7f36103e4a424ee4cd 1 parent cd41a53
Hamish Friedlander hafriedlander authored sminnee committed
37 tests/view/SSViewerTest.php
View
@@ -898,6 +898,41 @@ public function testNestedLoops(){
);
}
+ 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 @@ public function testThemeRetrieval() {
// 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
View
@@ -0,0 +1 @@
+Foo
1  tests/view/themes/layouttest/Layout/Shortcodes.ss
View
@@ -0,0 +1 @@
+[file_link]
1  tests/view/themes/layouttest/Page.ss
View
@@ -0,0 +1 @@
+$Layout
7 view/SSViewer.php
View
@@ -909,7 +909,12 @@ public function process($item, $arguments = null) {
$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)
+ );
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.