Re: [SMARTY-DEV] {strip}{/strip} unexpected results

From: Date: Thu, 17 Apr 2003 14:52:32 +0000
Subject: Re: [SMARTY-DEV] {strip}{/strip} unexpected results
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1218@lists.php.net to get a copy of this message
I committed a patch that should fix this without breaking anything else. It removes the newlines after PHP close tags before doing the strip, then replaces them afterwards. See if this works for you. Monte On Thu, 2003-04-17 at 08:07, Jan Rosier wrote: > 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. -- Monte Ohrt <monte@ispi.net>

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