From cdd2aae58268ab0c847d73c93a4c1322f211a89e Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Mon, 11 Jan 2010 17:58:10 +0000 Subject: [PATCH] - added \n to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source --- SMARTY2_BC_NOTES | 6 +++++- change_log.txt | 2 +- libs/sysplugins/smarty_internal_compile_if.php | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SMARTY2_BC_NOTES b/SMARTY2_BC_NOTES index adcf5e97..52c10bf6 100644 --- a/SMARTY2_BC_NOTES +++ b/SMARTY2_BC_NOTES @@ -69,4 +69,8 @@ as parameter. Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset. This is now used also on modifiers like escape as default charset. If your templates use other charsets make sure that you define the constant accordingly. Otherwise you may not -get any output. \ No newline at end of file +get any output. + +== newline at {if} tags == +A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source. +If one of the {if} tags is at the line end you will now get a newline in the HTML output. diff --git a/change_log.txt b/change_log.txt index f6a3faf4..1a100e34 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,5 @@ 01/11/2010 -- added \n to the compiled code of the {/if} tag to get output of newlines as expected by the template source +- added \n to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source 01/09/2010 - bugfix on nocache {block} tags in parent templates diff --git a/libs/sysplugins/smarty_internal_compile_if.php b/libs/sysplugins/smarty_internal_compile_if.php index c96741c2..d3fa9881 100644 --- a/libs/sysplugins/smarty_internal_compile_if.php +++ b/libs/sysplugins/smarty_internal_compile_if.php @@ -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 ''; + return "\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 ''; + return "\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 ''; + return "\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 '' . $tmp . ''; + return "{$tmp}\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 "\n"; + return "\n"; } }