Commit 77501e61 by Seldaek

git-svn-id: svn://dwoo.org/dwoo/trunk@103 0598d79b-80c4-4d41-97ba-ac86fbbd088b

parent 8d7eeff5
......@@ -21,7 +21,7 @@
*/
class Dwoo_Plugin_strip extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init($type = 'text')
public function init()
{
}
......@@ -34,17 +34,7 @@ class Dwoo_Plugin_strip extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Bl
{
$params = $compiler->getCompiledParams($params);
switch (trim($params['type'], '"\'')) {
case 'code':
$content = preg_replace('/\{[\r\n]+/', '{ ', preg_replace('#^\s*(.+?)\s*$#m', '$1', $content));
$content = str_replace(array("\n","\r"), null, $content);
break;
case 'text':
default:
$content = str_replace(array("\n","\r"), null, preg_replace('#^\s*(.+?)\s*$#m', '$1', $content));
}
$content = preg_replace(array("/\n/","/\r/",'/(<\?(?:php)?|<%)\s*/'), array('','','$1 '), preg_replace('#^\s*(.+?)\s*$#m', '$1', $content));
return $content;
}
......
......@@ -348,14 +348,11 @@ baz"));
$this->assertEquals("abca\nb\nc", $this->dwoo->get($tpl, array(), $this->compiler));
}
public function testStripCode()
public function testStripWithPhp()
{
$tpl = new Dwoo_Template_String("{strip code}
function foo() {
x;
}");
$tpl = new Dwoo_Template_String("{strip}a\nb{\$foo=\"\\n\"}{if \$foo}>{\$foo}<{/if}\nc{/strip}a\nb\nc");
$tpl->forceCompilation();
$this->assertEquals("function foo() { x;}", $this->dwoo->get($tpl, array(), $this->compiler));
$this->assertEquals("ab>\n<ca\nb\nc", $this->dwoo->get($tpl, array(), $this->compiler));
}
public function testTextFormat()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment