- 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

@@ -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.
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.

View File

@@ -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

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";
}
}