diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index 39e44264..6741c811 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -430,8 +430,7 @@ class Smarty_Compiler extends Smarty { if ($arg_name == 'file') { $include_file = $arg_value; continue; - } - elseif ($arg_name == 'assign') { + } else if ($arg_name == 'assign') { $assign_var = $arg_value; continue; } @@ -439,22 +438,26 @@ class Smarty_Compiler extends Smarty { $arg_value = $arg_value ? 'true' : 'false'; $arg_list[] = "'$arg_name' => $arg_value"; } + + $output = '_tpl_vars;\n" . - "\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" . - "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . - "unset(\$_smarty_tpl_vars);\n"; - $return .= "\$this->assign('".$this->_dequote($assign_var)."',ob_get_contents()); ob_end_clean();\n?>"; - } else { - $return = "_tpl_vars;\n" . - "\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" . - "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . - "unset(\$_smarty_tpl_vars); ?>"; - } - return $return; + $output .= "ob_start();\n"; + } + + $output .= + "\$_smarty_tpl_vars = \$this->_tpl_vars;\n" . + "\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" . + "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . + "unset(\$_smarty_tpl_vars);\n"; + + if (isset($assign_var)) { + $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n"; + } + + $output .= ' ?>'; + + return $output; } @@ -484,13 +487,14 @@ class Smarty_Compiler extends Smarty { } if (!empty($attrs['assign'])) { - $return = "assign('".$this->_dequote($attrs['assign'])."',ob_get_contents()); ob_end_clean();\n?>"; + $output = "assign(" . $this->_dequote($attrs['assign']).", ob_get_contents()); ob_end_clean();\n?>"; } else { - $return = ""; + $output = ""; } - return $return; + + return $output; } diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 39e44264..6741c811 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -430,8 +430,7 @@ class Smarty_Compiler extends Smarty { if ($arg_name == 'file') { $include_file = $arg_value; continue; - } - elseif ($arg_name == 'assign') { + } else if ($arg_name == 'assign') { $assign_var = $arg_value; continue; } @@ -439,22 +438,26 @@ class Smarty_Compiler extends Smarty { $arg_value = $arg_value ? 'true' : 'false'; $arg_list[] = "'$arg_name' => $arg_value"; } + + $output = '_tpl_vars;\n" . - "\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" . - "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . - "unset(\$_smarty_tpl_vars);\n"; - $return .= "\$this->assign('".$this->_dequote($assign_var)."',ob_get_contents()); ob_end_clean();\n?>"; - } else { - $return = "_tpl_vars;\n" . - "\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" . - "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . - "unset(\$_smarty_tpl_vars); ?>"; - } - return $return; + $output .= "ob_start();\n"; + } + + $output .= + "\$_smarty_tpl_vars = \$this->_tpl_vars;\n" . + "\$this->_smarty_include(".$include_file.", array(".implode(',', (array)$arg_list)."));\n" . + "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . + "unset(\$_smarty_tpl_vars);\n"; + + if (isset($assign_var)) { + $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n"; + } + + $output .= ' ?>'; + + return $output; } @@ -484,13 +487,14 @@ class Smarty_Compiler extends Smarty { } if (!empty($attrs['assign'])) { - $return = "assign('".$this->_dequote($attrs['assign'])."',ob_get_contents()); ob_end_clean();\n?>"; + $output = "assign(" . $this->_dequote($attrs['assign']).", ob_get_contents()); ob_end_clean();\n?>"; } else { - $return = ""; + $output = ""; } - return $return; + + return $output; }