aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_foreach.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_foreach.php')
-rw-r--r--vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_foreach.php10
1 files changed, 4 insertions, 6 deletions
diff --git a/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_foreach.php b/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_foreach.php
index 78b45ea7e..a68da5409 100644
--- a/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_foreach.php
+++ b/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_foreach.php
@@ -219,8 +219,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
if (isset($itemAttr[ 'index' ])) {
$output .= "{$itemVar}->index = -1;\n";
}
- $output .= "if (\$_from !== null) {\n";
- $output .= "foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
+ $output .= "{$itemVar}->do_else = true;\n";
+ $output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
+ $output .= "{$itemVar}->do_else = false;\n";
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
}
@@ -296,7 +297,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
if ($restore === 2) {
$output .= "{$itemVar} = {$local}saved;\n";
}
- $output .= "}\n} else {\n?>";
+ $output .= "}\nif ({$itemVar}->do_else) {\n?>";
return $output;
}
}
@@ -332,9 +333,6 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
if ($restore === 2) {
$output .= "{$itemVar} = {$local}saved;\n";
}
- if ($restore > 0) {
- $output .= "}\n";
- }
$output .= "}\n";
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
$foreachCompiler = $compiler->getTagCompiler('foreach');