summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-10-25 01:40:07 +0200
committerKevin Chabowski <kevin@kch42.de>2013-10-25 01:40:07 +0200
commitc3a72422e2b9754b60467387fd3cb660e0979e18 (patch)
tree26c4839a296e5abf90f7b0775defe6e99ca01337
parent2ffa4ae4253276af4c1266b73df3ddaf7ddf0051 (diff)
downloadste-c3a72422e2b9754b60467387fd3cb660e0979e18.tar.gz
ste-c3a72422e2b9754b60467387fd3cb660e0979e18.tar.bz2
ste-c3a72422e2b9754b60467387fd3cb660e0979e18.zip
Fixed some mistakes in mktag subcompiler
* Undeclared $code variable fixed. * "use ($mandatory_params)" only included, if the $mandatory_params variable will be generated. * Fixed $outputstack not being initialized correctly.
-rw-r--r--stupid_template_engine.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/stupid_template_engine.php b/stupid_template_engine.php
index db9028a..2cfb9d0 100644
--- a/stupid_template_engine.php
+++ b/stupid_template_engine.php
@@ -941,15 +941,19 @@ $ste_builtins = array(
},
"mktag" => function($ast)
{
+ $code = "";
+
if(empty($ast->params["name"]))
throw new ParseCompileError("Transcompile Error: name missing in <ste:mktag>.", $ast->tpl, $ast->offset);
$tagname = _transcompile($ast->params["name"], True);
- $fxbody = "\$outputstack = array(); \$outputstack_i = 0;\$ste->vars['_tag_parameters'] = \$params;\n";
+ $fxbody = "\$outputstack = array(''); \$outputstack_i = 0;\$ste->vars['_tag_parameters'] = \$params;\n";
+ $usemandatory = "";
if(!empty($ast->params["mandatory"]))
{
+ $usemandatory = " use (\$mandatory_params)";
$code .= "\$outputstack[] = '';\n\$outputstack_i++;\n";
$code .= _transcompile($ast->params["mandatory"]);
$code .= "\$outputstack_i--;\n\$mandatory_params = explode('|', array_pop(\$outputstack));\n";
@@ -960,7 +964,7 @@ $ste_builtins = array(
$fxbody .= _transcompile($ast->sub);
$fxbody .= "return array_pop(\$outputstack);";
- $code .= "\$tag_fx = function(\$ste, \$params, \$sub) use (\$mandatory_params)\n{\n" . indent_code($fxbody) . "\n};\n";
+ $code .= "\$tag_fx = function(\$ste, \$params, \$sub)" . $usemandatory . "\n{\n" . indent_code($fxbody) . "\n};\n";
$code .= "\$ste->register_tag($tagname, \$tag_fx);\n";
return $code;