[Templates] Chomping whitespace
Hann, Brian
Brian.Hann@umb.com
Wed, 18 Sep 2002 14:07:20 -0500
What if I don't even want a single space character?
I suppose I could write my own filter, or I could do it like this:
[% "The cat sat on the mat" FILTER remove('\s+') %]
(from the filters docpage)
Brian
-----Original Message-----
From: darren chamberlain [mailto:dlc@users.sourceforge.net]
Sent: Wednesday, September 18, 2002 2:01 PM
To: templates@template-toolkit.org
Subject: Re: [Templates] Chomping whitespace
* Hann, Brian <Brian.Hann@umb.com> [2002-09-18 14:46]:
> I know you can use [%- and -%] to chomp newlines without having to use
> PRE_CHOMP and POST_CHOMP, but is there a way to remove ALL whitespace
> before/after a directive without having to use configuration options?
Hm... Wrap everything with the collapse filter:
[% FILTER collapse %]
Your content here
[% END %]
See the Template::Filters perldoc.
collapse
"collapse" replaces any amount of whitespace with a
single space character. "collapse" uses Perl's defi-
nition of whitespace, which includes spaces, tabs,
carriage returns, newlines, and a few more esoteric
characters.
[% FILTER collapse %]
You'll love
it, it's a way
of life.
[% END %]
The output is nice and clean:
You'll love it, it's a way of life.
(darren)
--=20
Those who learn from history are doomed to have it repeated to
them anyway.
-- Larry Wall
_______________________________________________
templates mailing list
templates@template-toolkit.org
http://www.template-toolkit.org/mailman/listinfo/templates