From 6e94e1897faf5c0d8a23b927980bfcddd37ac8bb Mon Sep 17 00:00:00 2001 From: messju Date: Thu, 10 Feb 2005 15:14:15 +0000 Subject: [PATCH] fixed too agressive {strip} around delimiters inside strip-blocks --- libs/Smarty_Compiler.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 34ba9405..9311ae2c 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -325,14 +325,18 @@ class Smarty_Compiler extends Smarty { if ($compiled_tags[$i] == '{strip}') { $compiled_tags[$i] = ''; $strip = true; + /* remove leading whitespaces */ + $text_blocks[$i + 1] = ltrim($text_blocks[$i + 1]); } if ($strip) { /* strip all $text_blocks before the next '/strip' */ for ($j = $i + 1; $j < $for_max; $j++) { /* remove leading and trailing whitespaces of each line */ - $text_blocks[$j] = preg_replace('!\s+$|^\s+!m', '', $text_blocks[$j]); - /* remove carriage return and newline between each line */ - $text_blocks[$j] = preg_replace('![\r\n]+!m', '', $text_blocks[$j]); + $text_blocks[$j] = preg_replace('![\t ]*[\r\n]+[\t ]*!', '', $text_blocks[$j]); + if ($compiled_tags[$j] == '{/strip}') { + /* remove trailing whitespaces from the last text_block */ + $text_blocks[$j] = rtrim($text_blocks[$j]); + } $text_blocks[$j] = ""\'", "\\"=>"\\\\")) . "'; ?>"; if ($compiled_tags[$j] == '{/strip}') { $compiled_tags[$j] = "\n"; /* slurped by php, but necessary