On Tue, 1 Feb 2011 15:41:58 +0000, Roger Burton West wrote
> On Tue, Feb 01, 2011 at 05:14:36PM +0200, Offer Kaye wrote:
>
> >Is there any other solution?
>
> You've covered the two most usual approaches. Anything else will involve
> processing the string you get from the output() function.
$htmltemplatefilters = [
# remove any space at the start of a line if it is
immediately before a tmpl tag
{ sub => sub { my $text_aref = shift; s#^[\t
]+(</?tmpl_[^>]+>)#$1#gi for @{$text_aref} },
format => 'array' },
# remove any \n and \r following a tmpl tag
{ sub => sub { my $text_ref = shift; $$text_ref =~
s#(</?tmpl_[^>]+>)[\r\n]+#$1#sgi },
format => 'scalar' },
];
my $template = HTML::Template->new(
filename =>
get_template('example.tmpl'),
filter =>
$htmltemplatefilters,
);
thats how we handle it. So our code is readable, but the output result is
formatted correctly.
HTH,
Alex
|