Commit 4fc3c9ce by Seldaek

* Fixes an output buffering bug introduced by the performance tweaks

git-svn-id: svn://dwoo.org/dwoo/trunk@19 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 9e48c870
......@@ -4,7 +4,11 @@
! BC Break: $dwoo->output() and get() have been swapped internally, but it
doesn't change anything for you unless you called output(*, *, *, true)
directly to emulate get(). This was done to reduce some overhead
* Performance improvements
* Various performance improvements, including the removal of a lot of isset()
calls. Doing {$foo} if foo is undefined will now display a PHP warning, but
doing {foreach $foo}..{/foreach} will not however, that way you don't have
to do {if isset($foo)} before the foreach, but automated isset() calls don't
impact performance as much as they did before.
[2008-04-09] 0.3.4
......
......@@ -238,6 +238,13 @@ class Dwoo
protected $curBlock;
/**
* stores the output buffer during template runtime
*
* @var string
*/
protected $buffer;
/**
* constructor, sets the cache and compile dir to the default values
*/
public function __construct()
......@@ -408,6 +415,7 @@ class Dwoo
$this->scopeTree = array();
$this->stack = array();
$this->curBlock = null;
$this->buffer = '';
}
/*
......@@ -839,6 +847,11 @@ class Dwoo
$this->curBlock->buffer(ob_get_contents());
ob_clean();
}
else
{
$this->buffer .= ob_get_contents();
ob_clean();
}
$block = new $class($this);
......
......@@ -31,7 +31,7 @@ final class DwooPlugin_topLevelBlock extends DwooBlockPlugin
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
{
return DwooCompiler::PHP_OPEN.'return ob_get_clean();';
return DwooCompiler::PHP_OPEN.'return $this->buffer . ob_get_clean();';
}
}
......
......@@ -226,15 +226,20 @@ class BlockTests extends PHPUnit_Framework_TestCase
public function testTextFormat()
{
$tpl = new DwooTemplateString('{textformat wrap=10}hello world is so unoriginal but hey.. it works.{/textformat}');
$tpl = new DwooTemplateString('aa{textformat wrap=10}hello world is so unoriginal but hey.. {textformat wrap=4}a a a a a a{/textformat}it works.{/textformat}bb');
$tpl->forceCompilation();
$this->assertEquals('hello
$this->assertEquals('aahello
world is
so
unoriginal
but hey..
it works.', $this->dwoo->get($tpl, array(), $this->compiler));
a a
a a
a ait
works.bb', $this->dwoo->get($tpl, array(), $this->compiler));
$tpl = new DwooTemplateString('{textformat style=email indent=50}hello world is so unoriginal but hey.. it works.{/textformat}');
$tpl->forceCompilation();
......
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