package Text::Template::Preprocess;
$Text::Template::Preprocess::VERSION = '1.59';
# ABSTRACT: Expand template text with embedded Perl
use strict;
use warnings;
use Text::Template;
our @ISA = qw(Text::Template);
sub fill_in {
my $self = shift;
my (%args) = @_;
my $pp = $args{PREPROCESSOR} || $self->{PREPROCESSOR};
if ($pp) {
local $_ = $self->source();
my $type = $self->{TYPE};
# print "# fill_in: before <$_>\n";
&$pp;
# print "# fill_in: after <$_>\n";
$self->set_source_data($_, $type);
}
$self->SUPER::fill_in(@_);
}
sub preprocessor {
my ($self, $pp) = @_;
my $old_pp = $self->{PREPROCESSOR};
$self->{PREPROCESSOR} = $pp if @_ > 1; # OK to pass $pp=undef
$old_pp;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Text::Template::Preprocess - Expand template text with embedded Perl
=head1 VERSION
version 1.59
=head1 SYNOPSIS
use Text::Template::Preprocess;
my $t = Text::Template::Preprocess->new(...); # identical to Text::Template
# Fill in template, but preprocess each code fragment with pp().
my $result = $t->fill_in(..., PREPROCESSOR => \&pp);
my $old_pp = $t->preprocessor(\&new_pp);
=head1 DESCRIPTION
C