fix newline handling for template for all template tags

This commit is contained in:
mohrt
2003-06-16 14:38:57 +00:00
parent f4cc1ae921
commit cdfe88be6d

View File

@@ -309,6 +309,10 @@ class Smarty_Compiler extends Smarty {
/* Interleave the compiled contents and text blocks to get the final result. */ /* Interleave the compiled contents and text blocks to get the final result. */
for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
if ($compiled_tags[$i] == '') {
// tag result empty, remove first newline from following text block
$text_blocks[$i+1] = preg_replace('!^(\r\n|\r|\n)!', '', $text_blocks[$i+1]);
}
$template_compiled .= $text_blocks[$i].$compiled_tags[$i]; $template_compiled .= $text_blocks[$i].$compiled_tags[$i];
} }
$template_compiled .= $text_blocks[$i]; $template_compiled .= $text_blocks[$i];
@@ -552,8 +556,10 @@ class Smarty_Compiler extends Smarty {
*/ */
if ($found) { if ($found) {
if ($have_function) { if ($have_function) {
$output = '<?php ' . call_user_func_array($plugin_func, $output = call_user_func_array($plugin_func, array($tag_args, &$this));
array($tag_args, &$this)) . ' ?>'; if($output != '') {
$output = '<?php ' . $output . ' ?>';
}
} else { } else {
$this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
} }
@@ -684,7 +690,11 @@ class Smarty_Compiler extends Smarty {
$this->_parse_modifiers($return, $tag_modifier); $this->_parse_modifiers($return, $tag_modifier);
} }
return '<?php echo ' . $return . " ; ?>\n"; if($_return != '') {
$_return = '<?php echo ' . $_return . ' ; ?>';
}
return $_return;
} }
/** /**