behavior of newlines following template tags
| From: | Monte Ohrt | Date: | Fri, 09 Feb 2001 05:06:19 +0000 |
| Subject: | behavior of newlines following template tags | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-97@lists.php.net to get a copy of this message | ||
As Joris pointed out in an earlier e-mail, there is an inherent behavior
of PHP with newlines that may be undesirable in certain conditions.
Basically, a newline following a template tag implicitly gets stripped.
For example, a template consisting of:
Contact:
Name: {$name}
Country: {$country}
Would end up coming out like this:
Contact:
Name: Joris TroosterCountry: Netherlands
The newlines following {$name} and {$country} were stripped. This would
probably work fine if your templates consist of HTML where newlines
don't have much function. On the other hand, if your template is
formatting an e-mail for example, this behavior can be undesirable.
It is technically possible for Smarty to retain the carriage returns.
But, would this always be the desired behavior? For example, let's say
our template looks like this:
{if $email}
E-mail: {$email}
{else}
Your e-mail address isn't given.
{/if}
Would we want the newlines retained after the conditional tags, or only
after the {$email} tag is printed? In other words, do we make a rule
that newlines are only retained after a tag that actually prints a
value, and all other template tags do not?