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

From: Date: Thu, 17 Apr 2003 15:40:36 +0000
Subject: Re: [SMARTY-DEV] {strip}{/strip} unexpected results
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1220@lists.php.net to get a copy of this message
It looks like we did cross-post :) (sorry) I'll try your patch Greetings, Jan Rosier * "Oh dear, I think you'll find reality's on the blink again." -- Marvin The Paranoid Android * ----- Original Message ----- From: "Monte Ohrt" <monte@ispi.net> To: "Jan Rosier" <rosier@interstroom.nl> Cc: "Smarty Dev" <smarty-dev@lists.php.net> Sent: Thursday, April 17, 2003 4:52 PM Subject: Re: [SMARTY-DEV] {strip}{/strip} unexpected results > 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> > > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

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