outputfilter.trimwhitespace
| From: | Lars Noschinski | Date: | Sat, 25 Jan 2003 13:44:34 +0000 |
| Subject: | outputfilter.trimwhitespace | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-619@lists.php.net to get a copy of this message | ||
Hello!
I made some changes to the trimwhitespace outputfilter:
1) Trim all leading whitespace to allow the output of correct X(HT)ML
documents. I've done this with an additional trim, as this seemed
easier for me than changing the regex.
2) Don't touch whitespace in textarea blocks, as they are also preformatted.
Here's the diff against current cvs (r1.1):
33a34,39
> // Pull out the script blocks
> preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source,
> $match);
> $_textarea_blocks = $match[0];
> $source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
> '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
>
36c42
< $source = preg_replace('/((?<!\?>)\n)[\s]+/m', '\1',
$source);
---
> $source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m',
> '\1', $source));
44a51,55
> }
>
> // replace textarea blocks
> foreach($_textarea_blocks as $curr_block) {
> $source =
> preg_replace("!@@@SMARTY:TRIM:TEXTAREA@@@!",$curr_block,$source,1);