Commit 860ce2d9 by Seldaek

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

parent 548e0f1e
...@@ -28,9 +28,8 @@ ...@@ -28,9 +28,8 @@
of its compile() method of its compile() method
+ API: Added a bunch of utility functions to Dwoo_Compiler, allowing compiled + API: Added a bunch of utility functions to Dwoo_Compiler, allowing compiled
plugins to access more of the compiler internals plugins to access more of the compiler internals
* Fixed a potential concurrency issue (thanks to Rasmus Schultz for the patch)
* Moved all files to Dwoo/Class.php excepted for the core Dwoo.php file * Moved all files to Dwoo/Class.php excepted for the core Dwoo.php file
* Fixed a classpath rebuilding bug that occured on some UNIX platforms due to
glob() returning false sometimes for empty folders
* Various performance improvements, including the removal of a lot of isset() * 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 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 doing {foreach $foo}..{/foreach} will not however, that way you don't have
...@@ -42,13 +41,18 @@ ...@@ -42,13 +41,18 @@
* {include} now uses the current resource if none is provided instead of using * {include} now uses the current resource if none is provided instead of using
file as it did before file as it did before
* Dwoo uses include path instead of absolute includes * Dwoo uses include path instead of absolute includes
* Fixed a regression in the handling of custom class plugins
* Fixed a bug in Dwoo_Security_Policy->getAllowedDirectories(), no security
issue though
* Changed all line endings to Unix (line feed only) and all spaces left have * Changed all line endings to Unix (line feed only) and all spaces left have
been converted to tabs (tabspace 4) been converted to tabs (tabspace 4)
* TestFest happened early for Dwoo, lots of new tests and more code covered * TestFest happened early for Dwoo, lots of new tests and more code covered
* Fixed a regression in the handling of custom class plugins
* Fixed various bugs in the Adapter class and related smarty compatibility
features
* Fixed a classpath rebuilding bug that occured on some UNIX platforms due to
glob() returning false sometimes for empty folders
* Fixed a bug in Dwoo_Security_Policy->getAllowedDirectories(), no security
issue though
* Fixed a bug in Dwoo::setScope affecting {loop} and {with} * Fixed a bug in Dwoo::setScope affecting {loop} and {with}
* Fixed a parsing bug when doing {"string"|modifier:$var}
[2008-04-09] 0.3.4 [2008-04-09] 0.3.4
! BC Break: DWOO_PATH constant changed to DWOO_DIRECTORY ! BC Break: DWOO_PATH constant changed to DWOO_DIRECTORY
......
...@@ -1330,6 +1330,8 @@ class Dwoo_Compiler implements Dwoo_ICompiler ...@@ -1330,6 +1330,8 @@ class Dwoo_Compiler implements Dwoo_ICompiler
} }
if($curBlock !== 'modifier' && substr($in, $strend+1, 1)==='|') if($curBlock !== 'modifier' && substr($in, $strend+1, 1)==='|')
{ {
if($strend !== false)
$realend = $strend-$from+1;
$strend = strpos($in, ' ', $strend+1); $strend = strpos($in, ' ', $strend+1);
if($strend===false) if($strend===false)
$strend = strlen($in)-1; $strend = strlen($in)-1;
...@@ -1339,7 +1341,10 @@ class Dwoo_Compiler implements Dwoo_ICompiler ...@@ -1339,7 +1341,10 @@ class Dwoo_Compiler implements Dwoo_ICompiler
if($pointer !== null) if($pointer !== null)
$pointer += strlen($srcOutput); $pointer += strlen($srcOutput);
$output = $this->replaceStringVars($srcOutput, $first); if(isset($realend))
$output = $this->replaceStringVars(substr($srcOutput, 0, $realend), $first) . substr($srcOutput, $realend);
else
$output = $this->replaceStringVars($srcOutput, $first);
// handle modifiers // handle modifiers
if($curBlock !== 'modifier' && preg_match('#(.+?)((?:\|(?:@?[a-z0-9_]+(?::[^\s]*)*))+)#i', $output, $match)) if($curBlock !== 'modifier' && preg_match('#(.+?)((?:\|(?:@?[a-z0-9_]+(?::[^\s]*)*))+)#i', $output, $match))
......
...@@ -38,6 +38,30 @@ class CompilerTests extends PHPUnit_Framework_TestCase ...@@ -38,6 +38,30 @@ class CompilerTests extends PHPUnit_Framework_TestCase
$this->assertEquals('B-A-R', $this->dwoo->get($tpl, array('foo'=>'bar'), $this->compiler)); $this->assertEquals('B-A-R', $this->dwoo->get($tpl, array('foo'=>'bar'), $this->compiler));
} }
public function testModifierArgsVars()
{
$tpl = new Dwoo_Template_String('{$foo|spacify:$bar|upper}');
$tpl->forceCompilation();
$this->assertEquals('B-A-R', $this->dwoo->get($tpl, array('foo'=>'bar', 'bar'=>'-'), $this->compiler));
}
public function testModifierOnString()
{
$tpl = new Dwoo_Template_String('{"bar"|spacify:"-"|upper}');
$tpl->forceCompilation();
$this->assertEquals('B-A-R', $this->dwoo->get($tpl, array(), $this->compiler));
}
public function testModifierOnStringWithVar()
{
$tpl = new Dwoo_Template_String('{"bar"|spacify:$bar|upper}');
$tpl->forceCompilation();
$this->assertEquals('B-A-R', $this->dwoo->get($tpl, array('bar'=>'-'), $this->compiler));
}
public function testModifierWithModifier() public function testModifierWithModifier()
{ {
$tpl = new Dwoo_Template_String('{$foo.0}{assign $foo|reverse foo}{$foo.0}{assign $foo|@reverse foo}{$foo.0}'); $tpl = new Dwoo_Template_String('{$foo.0}{assign $foo|reverse foo}{$foo.0}{assign $foo|@reverse foo}{$foo.0}');
......
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