mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
fix newline handling for template for all template tags
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user