Plagger::Plugin::Publish::Templateを改��
読了まで:約0分
概要: Plagger::Plugin::Publish::Template を
自分で
で、
sub feed {
my($self, $context, $args) = @_;
my $file = Plagger::Util::filename_for($args->{feed}, $self->conf->{filename} || '%i.txt');
my $path = File::Spec->catfile($self->conf->{dir}, $file);
$context->log(info => "writing output to $path");
# 変数の展開
my $variables = { feed => $args->{'feed'} };
my $vars = $self->conf->{'variable'} || {};
for my $key ( keys %{ $vars } ) {
my $result = eval $vars->{$key};
if ( $@ ) {
$context->error( $@ );
}
else {
$variables->{$key} = $result;
}
}
my $body = $self->templatize( $self->conf->{'template'} , $variables );
open my $out, ">:utf8", $path or $context->error("$path: $!");
print $out $body;
close $out;
}
plugins:
- module: Publish::Template
rule:
expression: require Plagger::Date; 1;
config:
template: template.tt
filename: output.txt
dir: /path/to/output/dir
variable:
now: Plagger::Date->now
conf: $self->conf
こんな
Windows で
開発環境整えないと
追記
明らかに
#FIXME