{strip}{/strip} unexpected results

From: Date: Thu, 17 Apr 2003 13:07:53 +0000
Subject: {strip}{/strip} unexpected results
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1216@lists.php.net to get a copy of this message
Hello all, I found that {strip}{/strip} does not always work as you might expect. I will try to explain this with an example In php: $smarty->assign('firstname', 'John'); $smarty->assign('lastname', 'Smith'); Template: {strip} <P> {$firstname}{if $lastname neq ''} {$lastname}{/if} </P> {/strip} {strip} <P> {$firstname} {$lastname} </P> {/strip} Output: <P>John Smith</P> <P>JohnSmith</P> The output of the first paragraph is as expected. The second one not. Here the space between John and Smith is stripped out After some digged in Smarty_Compiler.class.php v2.5.0 I found that the compiler inserts extra newlines, which interfere with the code that is use for strip (line 308 - 317) I changed line 396: return "<?php echo $_return; ?>\n"; to: return '<?php echo ' . $_return . '; ?>'; Now the output of the second paragraph is the same as the output of the first paragraph. Why does the Smarty compiler insert extra newlines in the compiled template? Does my change break anything else? If not, then it would be nice if this change was put in the distribution as well. Greetings Jan Rosier.

« previous php.smarty.dev (#1216) next »