/usr/share/perl5/Catmandu/Fix/template.pm is in libcatmandu-template-perl 0.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | package Catmandu::Fix::template;
use Moo;
use Template;
use Catmandu;
use Catmandu::Fix::Has;
with 'Catmandu::Fix::Base';
has path => (fix_arg => 1);
has value => (fix_arg => 1);
sub emit {
my ($self, $fixer) = @_;
my $path = $fixer->split_path($self->path);
my $value = $fixer->emit_value($self->value);
my $tt = $fixer->capture(Template->new);
$fixer->emit_create_path(
$fixer->var,
$path,
sub {
my $var = shift;
my $root = $fixer->var;
my $output = $fixer->generate_var;
my $perl = $fixer->emit_declare_vars($output, '""');
$perl .= "${tt}->process(\\${value},${root},\\${output});";
$perl .= "${var} = ${output};";
$perl;
}
);
}
=head1 NAME
Catmandu::Fix::template - add a value to the record based on a template
=head1 SYNOPSIS
# Your record contains:
#
# name: John
# age: 44
template(message,"Mr [%name%] is [%age%] years old")
# Result:
#
# name: John
# age: 44
# message: Mr John is 44 years old
=head1 SEE ALSO
L<Catmandu::Fix>, L<Template>
=cut
1;
|