Commit 918408ef by Seldaek

+ Added {do} that executes whatever you feed it whitout echoing the result, used…

+ Added {do} that executes whatever you feed it whitout echoing the result, used internally for extends but you can use it if you find a use for it git-svn-id: svn://dwoo.org/dwoo/trunk@25 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 717845de
...@@ -1109,7 +1109,7 @@ class DwooCompiler implements DwooICompiler ...@@ -1109,7 +1109,7 @@ class DwooCompiler implements DwooICompiler
if($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : 0) + strlen($func)).' TO POINTER<br/>'; if($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : 0) + strlen($func)).' TO POINTER<br/>';
} }
if($curBlock === 'method') if($curBlock === 'method' || $func === 'do')
{ {
$pluginType = Dwoo::NATIVE_PLUGIN; $pluginType = Dwoo::NATIVE_PLUGIN;
} }
...@@ -1175,10 +1175,25 @@ class DwooCompiler implements DwooICompiler ...@@ -1175,10 +1175,25 @@ class DwooCompiler implements DwooICompiler
$p = $p[0]; $p = $p[0];
if($pluginType & Dwoo::NATIVE_PLUGIN) if($pluginType & Dwoo::NATIVE_PLUGIN)
{ {
if(isset($params['*'])) if($func === 'do')
$output = $func.'('.implode(', ', $params['*']).')'; {
if(isset($params['*']))
$output = implode(';', $params['*']).';';
else
$output = '';
if(is_array($parsingParams) || $curBlock !== 'root')
return $this->triggerError('Do can not be used inside another function or block', E_USER_ERROR);
else
return self::PHP_OPEN.$output.self::PHP_CLOSE;
}
else else
$output = $func.'()'; {
if(isset($params['*']))
$output = $func.'('.implode(', ', $params['*']).')';
else
$output = $func.'()';
}
} }
elseif($pluginType & Dwoo::FUNC_PLUGIN) elseif($pluginType & Dwoo::FUNC_PLUGIN)
{ {
......
...@@ -111,7 +111,7 @@ class DwooPlugin_extends extends DwooPlugin implements DwooICompilable ...@@ -111,7 +111,7 @@ class DwooPlugin_extends extends DwooPlugin implements DwooICompilable
$newSource = $parent['source']; $newSource = $parent['source'];
$newSource = preg_replace_callback('/'.self::$l.'block (["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)(.*?)(?:\r?\n?)'.self::$l.'\/block'.self::$r.'/is', array('DwooPlugin_extends', 'replaceBlock'), $newSource); $newSource = preg_replace_callback('/'.self::$l.'block (["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)(.*?)(?:\r?\n?)'.self::$l.'\/block'.self::$r.'/is', array('DwooPlugin_extends', 'replaceBlock'), $newSource);
$newSource = $l.'extendsCheck "'.$parent['resource'].':'.$parent['identifier'].'" "'.str_replace('"', '\\"', $parent['uid']).'"'.$r.$newSource; $newSource = $l.'do extendsCheck("'.$parent['resource'].':'.$parent['identifier'].'" "'.str_replace('"', '\\"', $parent['uid']).'")'.$r.$newSource;
if(self::$lastReplacement) if(self::$lastReplacement)
break; break;
......
...@@ -25,7 +25,7 @@ function DwooPlugin_extendsCheck_compile(DwooCompiler $compiler, $file, $uid) ...@@ -25,7 +25,7 @@ function DwooPlugin_extendsCheck_compile(DwooCompiler $compiler, $file, $uid)
$resource = $m[1]; $resource = $m[1];
$identifier = $m[2]; $identifier = $m[2];
return '\'\'; // check for modification in '.$resource.':'.$identifier.' return '// check for modification in '.$resource.':'.$identifier.'
try { try {
$tpl = $this->getTemplate("'.$resource.'", "'.$identifier.'"); $tpl = $this->getTemplate("'.$resource.'", "'.$identifier.'");
} catch (DwooException $e) { } catch (DwooException $e) {
......
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