Re: [SMARTY-DEV] Newlines
| From: | Andrei Zmievski | Date: | Thu, 04 Apr 2002 17:43:37 +0000 |
| Subject: | Re: [SMARTY-DEV] Newlines | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-24@lists.php.net to get a copy of this message | ||
On Thu, 04 Apr 2002, Monte Ohrt wrote:
> Ah yes, the problem extends from the fact that PHP eats carriage returns
> immediately after a php close tag. We cannot simply remove this \n in
> Smarty, it will cause incorrect formatting.
>
> I have attached a revised version of trimwhitespace, it is actually more
> efficient since one regex now takes care of both leading spaces and
> empty lines. This is accomplished with a negative match look behind,
> which PCRE thankfully supports ;-)
>
> I'm also trying to figure out a way to selectively disable
> trimwhitespace (besides unregistering the function.) For instance, if
> your template is an e-mail message, you don't want to trim it! My first
> thought was to look for {* trimwhitespace off *} in the template, but in
> a post filter that would already be removed. We could change Smarty so
> that Smarty comments are kept in the source, so {* foo *} would be come
> <?php /* foo */ ?> in the compiled template. Any thoughts on this?
I would be against it. More parsing for PHP, and controlling plugins
via embedded comments does not seem good.
-Andrei
"The day Microsoft makes something that doesn't suck,
is probably the day Microsoft starts making vacuum cleaners."
- Ernst Jan Plugge