From 03430c4f942e66276a3cd797aa82e8e89b37e90e Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Fri, 20 Jan 2023 23:16:41 +0100 Subject: [PATCH] Fixed block append/prepend functionality --- src/Compile/Tag/BlockClose.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Compile/Tag/BlockClose.php b/src/Compile/Tag/BlockClose.php index 10ef3b7b..b67777f0 100644 --- a/src/Compile/Tag/BlockClose.php +++ b/src/Compile/Tag/BlockClose.php @@ -24,6 +24,15 @@ class BlockClose extends Inheritance { $_name = $_attr['name']; $_assign = $_attr['assign'] ?? null; + unset($_attr[ 'assign' ], $_attr[ 'name' ]); + + $_block = []; + + foreach ($_attr as $name => $stat) { + if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat !== 'false')) { + $_block[ $name ] = 'true'; + } + } // get compiled block code $_functionCode = $compiler->getParser()->current_buffer; @@ -33,6 +42,9 @@ class BlockClose extends Inheritance { $output .= $compiler->cStyleComment(" {block {$_name}} ") . "\n"; $output .= "class {$_className} extends \\Smarty\\Runtime\\Block\n"; $output .= "{\n"; + foreach ($_block as $property => $value) { + $output .= "public \${$property} = " . var_export($value, true) . ";\n"; + } $output .= "public function callBlock(\\Smarty\\Template \$_smarty_tpl) {\n"; if ($compiler->getTemplate()->getCompiled()->getNocacheCode()) { $output .= "\$_smarty_tpl->getCached()->hashes['{$compiler->getTemplate()->getCompiled()->nocache_hash}'] = true;\n";