Quoting Drew Taylor <[EMAIL PROTECTED]> [Feb 27, 2002 21:39]:
> Hi all,
>
> I'm having a problem w/ filters. The overview is that the filter is being
> called, but no args are passed to it. My configuration is below. This is w/
> version 2.04. Any thoughts? I've used filters before w/o any problems.
>
> my %opts = (
> INCLUDE_PATH => $path,
> PRE_CHOMP => 1,
> TRIM => 1,
> PRE_PROCESS => 'header.html',
> POST_PROCESS => 'footer.html',
> COMPILE_DIR => $path.'/cache',
> COMPILE_EXT => '.ttc2',
> FILTERS => { commify => \&commify, },
> );
>
> sub commify {
> debug('',"Commify args '@_'");
> my $text = shift;
> debug('',"Commifying '$text'");
> $text = reverse $text;
> $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
> $text = scalar reverse $text;
> debug('',"Commified text: '$text'");
> return $text;
> }
>
> Here's the results when called from a template via [% disk | commify %]:
>
> Pair::Admin::commify: Commify args ''
> Pair::Admin::commify: Commifying ''
> Pair::Admin::commify: Commified text: ''
Does the code work if you install the same subroutine ref as a
virtual method, or pass it in as part of %params to process?
I.e:
my %opts = (
INCLUDE_PATH => $path,
PRE_CHOMP => 1,
TRIM => 1,
PRE_PROCESS => 'header.html',
POST_PROCESS => 'footer.html',
COMPILE_DIR => $path.'/cache',
COMPILE_EXT => '.ttc2',
);
$Template::Stash::SCALAR_OPS->{ 'commify' } = \&commify;
And then call it as [% disk.commify %]
Or if you pass the subroutine into the hashref to process:
$t->process($file, { commify => \&commify });
And call it as [% commify(disk) %]
(darren)
--
Of all the strange 'crimes' that human beings have legislated out of
nothing, 'blasphemy' is the most amazing--with 'obscenity' and
'indecent exposure' fighting it out for second and third place.
-- Lazarus Long