line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Moo; |
3
|
1
|
|
|
1
|
|
86550
|
use Template; |
|
1
|
|
|
|
|
9119
|
|
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
1578
|
use Catmandu; |
|
1
|
|
|
|
|
17355
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
428
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
236379
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
1121
|
|
|
1
|
|
|
|
|
798
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
with 'Catmandu::Fix::Base'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
10
|
|
|
|
|
|
|
has value => (fix_arg => 1); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my ($self, $fixer) = @_; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
0
|
2888
|
my $path = $fixer->split_path($self->path); |
15
|
|
|
|
|
|
|
my $value = $fixer->emit_value($self->value); |
16
|
1
|
|
|
|
|
8
|
my $tt = $fixer->capture(Template->new); |
17
|
1
|
|
|
|
|
30
|
|
18
|
1
|
|
|
|
|
41
|
$fixer->emit_create_path( |
19
|
|
|
|
|
|
|
$fixer->var, |
20
|
|
|
|
|
|
|
$path, |
21
|
|
|
|
|
|
|
sub { |
22
|
|
|
|
|
|
|
my $var = shift; |
23
|
|
|
|
|
|
|
my $root = $fixer->var; |
24
|
1
|
|
|
1
|
|
70
|
my $output = $fixer->generate_var; |
25
|
1
|
|
|
|
|
18
|
my $perl = $fixer->emit_declare_vars($output, '""'); |
26
|
1
|
|
|
|
|
10
|
$perl .= "${tt}->process(\\${value},${root},\\${output});"; |
27
|
1
|
|
|
|
|
11
|
$perl .= "${var} = ${output};"; |
28
|
1
|
|
|
|
|
18
|
$perl; |
29
|
1
|
|
|
|
|
4
|
} |
30
|
1
|
|
|
|
|
3
|
); |
31
|
|
|
|
|
|
|
} |
32
|
1
|
|
|
|
|
23410
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Catmandu::Fix::template - add a value to the record based on a template |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Your record contains: |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
# name: John |
42
|
|
|
|
|
|
|
# age: 44 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
template(message,"Mr [%name%] is [%age%] years old") |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Result: |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# name: John |
49
|
|
|
|
|
|
|
# age: 44 |
50
|
|
|
|
|
|
|
# message: Mr John is 44 years old |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L<Catmandu::Fix>, L<Template> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |