Re: [SMARTY-DEV] Incorrect newline counters

From: Date: Wed, 02 Jun 2004 08:42:27 +0000
Subject: Re: [SMARTY-DEV] Incorrect newline counters
References: 1 2 3 4 5 6 7 8 9  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2369@lists.php.net to get a copy of this message
On Wed, Jun 02, 2004 at 09:36:50AM +0200, messju mohr wrote: > On Tue, Jun 01, 2004 at 04:42:53PM -0500, Monte Ohrt wrote: > > I think this rule works: If a tag produces no output, then no newline > > should be produced by it. > > > > examples: > > > > {$foo} > > {$foo2} > > {$foo3} > > > > The above vars should make newlines in the resulting template since they > > have output (even if it's empty). > > > > {assign var="foo" value="bar"} > > {assign var="foo2" value="bar2"} > > {assign var="foo3" value="bar3"} > > {if ...} > > {/if} > > {include ...} > > > > The above functions should NOT make newlines in the resulting template, > > there is no output. They are purely functional. > > that's not correct for assign. sorry, correction: a trailing newline after {assign} actually *gets* slurped. this is because {assign} isn't a custom-function but a compiler-function. I don't know why compiler-functions don't get a newline added after the closing php-tag. i think it was simply forgotten. > the rule is not "If a tag produces output then a newline after a > right-delimiter is kept" > > but it is "If a tag *is supposed to* produce then a newline after a > right-delimiter is kept" > > custom-function are supposed to produce output, so the newline after > an {assign} won't be slurped. > > > > > Tags that keep a following newline > > {$var} > {$obj->meth()} {* except when an assign-attribute is given *} > {obj->meth foo=bar} {* except when an assign-attribute is given *} > {function foo=bar} {* except the built-ins include and include_php *} > > > Tags that slurp a following newline > > {$obj->meth() assign=var} > {obj->meth assign=bar} > {obj->block ...} ... {/obj->block} > > {block} ... {/block} {* including all built-ins like foreach, section, if, literal ... *} > {else} > {foreachelse} > {sectionelse}

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