Commit a19f48d3 by Seldaek

* Plugins: Added a "trim" parameter to {capture} that trims the captured text

git-svn-id: svn://dwoo.org/dwoo/trunk@95 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 1c811341
......@@ -1939,6 +1939,9 @@ class Dwoo_Compiler implements Dwoo_ICompiler
} elseif (is_numeric($substr)) {
if ($this->debug) echo 'NUMBER PARSED<br />';
$substr = (float) $substr;
if ((int) $substr == $substr) {
$substr = (int) $substr;
}
} elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) {
if ($this->debug) echo 'SIMPLE MATH PARSED<br />';
$substr = '('.$substr.')';
......
......@@ -38,7 +38,7 @@
*/
class Dwoo_Plugin_capture extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init($name = 'default', $assign = null, $cat = false)
public function init($name = 'default', $assign = null, $cat = false, $trim = false)
{
}
......@@ -52,10 +52,13 @@ class Dwoo_Plugin_capture extends Dwoo_Block_Plugin implements Dwoo_ICompilable_
$params = $compiler->getCompiledParams($params);
$out = Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();';
if ($params['cat'] === 'true') {
if ($params['trim'] !== 'false' && $params['trim'] !== 0) {
$out .= "\n".'$tmp = trim($tmp);';
}
if ($params['cat'] === 'true' || $params['cat'] === 1) {
$out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;';
}
if ($params['assign'] !== "null") {
if ($params['assign'] !== 'null') {
$out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;';
}
return $out . "\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE;
......
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