mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
Fixed block append/prepend functionality
This commit is contained in:
@@ -24,6 +24,15 @@ class BlockClose extends Inheritance {
|
|||||||
|
|
||||||
$_name = $_attr['name'];
|
$_name = $_attr['name'];
|
||||||
$_assign = $_attr['assign'] ?? null;
|
$_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
|
// get compiled block code
|
||||||
$_functionCode = $compiler->getParser()->current_buffer;
|
$_functionCode = $compiler->getParser()->current_buffer;
|
||||||
@@ -33,6 +42,9 @@ class BlockClose extends Inheritance {
|
|||||||
$output .= $compiler->cStyleComment(" {block {$_name}} ") . "\n";
|
$output .= $compiler->cStyleComment(" {block {$_name}} ") . "\n";
|
||||||
$output .= "class {$_className} extends \\Smarty\\Runtime\\Block\n";
|
$output .= "class {$_className} extends \\Smarty\\Runtime\\Block\n";
|
||||||
$output .= "{\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";
|
$output .= "public function callBlock(\\Smarty\\Template \$_smarty_tpl) {\n";
|
||||||
if ($compiler->getTemplate()->getCompiled()->getNocacheCode()) {
|
if ($compiler->getTemplate()->getCompiled()->getNocacheCode()) {
|
||||||
$output .= "\$_smarty_tpl->getCached()->hashes['{$compiler->getTemplate()->getCompiled()->nocache_hash}'] = true;\n";
|
$output .= "\$_smarty_tpl->getCached()->hashes['{$compiler->getTemplate()->getCompiled()->nocache_hash}'] = true;\n";
|
||||||
|
Reference in New Issue
Block a user