diff --git a/src/SurfStack/Templating/Template_Engine.php b/src/SurfStack/Templating/Template_Engine.php index 19e81d6..86d5da5 100644 --- a/src/SurfStack/Templating/Template_Engine.php +++ b/src/SurfStack/Templating/Template_Engine.php @@ -757,8 +757,8 @@ protected function getRequiredClasses($class) return join(PHP_EOL, array_reverse($arrRequire)); } - public $pre; public $post; + public $plugrex; /** * Replace plugin tags with PHP code @@ -767,11 +767,12 @@ protected function getRequiredClasses($class) */ protected function parsePlugins($content) { - $this->pre = true; $this->post = false; + $this->plugrex = array_values($this->loadPlugins()); + // Load the plugin content and replace - return preg_replace_callback(array_values($this->loadPlugins()), function($matches) { + return preg_replace_callback($this->plugrex, function($matches) { $pluginName = $matches[1]; $pluginData = $matches[2]; // Block has content, Slice does not diff --git a/tests/SurfStack/Templating/Template_Engine_Test.php b/tests/SurfStack/Templating/Template_Engine_Test.php index 7d65d26..aaf7ef7 100644 --- a/tests/SurfStack/Templating/Template_Engine_Test.php +++ b/tests/SurfStack/Templating/Template_Engine_Test.php @@ -356,10 +356,33 @@ public function testPrePost() $this->render(); - $this->assertTrue($this->view->pre); $this->assertTrue($this->view->post); } + public function testPlugRex() + { + $this->view->clear(); + + $this->view->assign('test', 'Hello world'); + + $this->view->setTemplate('blockVariable.tpl'); + + $this->view->setLoadPlugins(true); + + $this->view->setStripTags(false); + + $this->view->setStripWhitespace(false); + + $this->render(); + + $this->assertSame($this->view->plugrex, array( + 0 => '/\{\s*(Blank)\s*(.*?)\}/i', + 1 => '/\{\s*(Bold)\s*(.*?)\}(.[^\}\{]*?)\{\/\s*Bold\s*\}/i', + 2 => '/\{\s*(Passthru)\s*(.*?)\}(.[^\}\{]*?)\{\/\s*Passthru\s*\}/i', + 3 => '/\{\s*(Time)\s*(.*?)\}/i', + )); + } + public function testSlice() { $this->expectOutputString(date('Y'));