Re: Filter to strip comments?
| From: | Tom Beddard | Date: | Wed, 19 Feb 2003 14:49:58 +0000 |
| Subject: | Re: Filter to strip comments? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7883@lists.php.net to get a copy of this message | ||
Thanks Joscha, i've added:
// Remove all html comments
$source = preg_replace("/<!--([^>])*-->/",'', $source);
to the outputfilter.trimwhitespace plugin before the trim() line and it
works a treat.
One nice final addition would be to be able to remove javascript comments,
i.e. start with // Comment and end with a carriage return
The trimwhitespace plugin isolates the javascript blocks, so i guess it
should be possible to loop through these and remove the JS comments too. Any
ideas on the regex for this?
Cheers,
Tom
> > Has anyone written an plugin to strip <!-- html style
> > comments --> from the
> > final output?
>
> Don't know, but this should do the work:
> preg_replace('/<!--([^>])*-->/',"", $source);
>
> Greets,
> Joscha
>
>