- added \n to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source

This commit is contained in:
Uwe.Tews
2010-01-11 17:58:10 +00:00
parent 64503880b3
commit cdd2aae582
3 changed files with 11 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
$_output .= "if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."){?>";
return $_output;
} else {
return '<?php if (' . $args['if condition'] . '){?>';
return "<?php if ({$args['if condition']}){?>\n";
}
}
}
@@ -53,7 +53,7 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif'));
$this->_open_tag('else',array($nesting,$compiler->tag_nocache));
return '<?php }else{ ?>';
return "<?php }else{ ?>\n";
}
}
@@ -79,13 +79,13 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
if (empty($this->compiler->prefix_code)) {
$this->_open_tag('elseif', array($nesting, $compiler->tag_nocache));
return '<?php }elseif(' . $args['if condition'] . '){?>';
return "<?php }elseif({$args['if condition']}){?>\n";
} else {
$tmp = '';
foreach ($this->compiler->prefix_code as $code) $tmp .= $code;
$this->compiler->prefix_code = array();
$this->_open_tag('elseif', array($nesting + 1, $compiler->tag_nocache));
return '<?php }else{?>' . $tmp . '<?php if (' . $args['if condition'] . '){?>';
return "<?php }else{?>{$tmp}<?php if ({$args['if condition']}){?>\n";
}
}
}
@@ -107,7 +107,7 @@ class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase {
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'else', 'elseif'));
$tmp = '';
for ($i = 0; $i < $nesting ; $i++) $tmp .= '}';
return "<?php $tmp?>\n";
return "<?php {$tmp}?>\n";
}
}