package Iotta::Filter::Template;
use base Iotta::Elem;
use strict;
#our @ISA = ("Iotta::Elem");
# XXX make template get method configurable
sub filter {
my $self = shift;
my $in = shift;
my $out = "";
open TPL, $self->templf;
$out .= $_ while (<TPL>);
close TPL;
$out =~ s/\$\$TEMPLATE-REPLACE\$\$/$in/g;
return $out;
}
sub run {
my $s = shift;
my $meta = shift;
my $data = shift;
my $ndata = $s->filter ($data);
print STDERR " template...\n";
$s->next->run($meta, $ndata) if ($s->next);
}
sub setup {
my $self = shift;
my $o = shift;
$self->templf ($$o{template});
}
sub initialize {
my $self = shift;
$self->SUPER::initialize (@_);
$self->{templf}="";
}
1;
Platon Group <platon@platon.sk> http://platon.sk/
|