line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
71233
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Template::Plugin::Transformator; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: TemplateToolkit plugin for Net::NodeTransformator |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
527
|
use Net::NodeTransformator; |
|
1
|
|
|
|
|
70924
|
|
|
1
|
|
|
|
|
32
|
|
9
|
1
|
|
|
1
|
|
578
|
use Template::Plugin::Filter; |
|
1
|
|
|
|
|
1617
|
|
|
1
|
|
|
|
|
32
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw( Template::Plugin::Filter ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
303
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init { |
15
|
1
|
|
|
1
|
0
|
59
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
50
|
|
|
13
|
$self->{config} = |
18
|
|
|
|
|
|
|
$self->{_CONTEXT}->{CONFIG}->{PLUGIN_CONFIG}->{Transformator} || {}; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
2
|
my %config = %{ $self->{_CONFIG} }; |
|
1
|
|
|
|
|
3
|
|
21
|
1
|
|
|
|
|
1
|
my @args = @{ $self->{_ARGS} }; |
|
1
|
|
|
|
|
2
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
50
|
|
|
4
|
my $name = $config{name} || 'Transformator'; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
2
|
$self->{_DYNAMIC} = 1; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
4
|
$self->install_filter($name); |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
42
|
$self->{nnt} = |
30
|
|
|
|
|
|
|
$self->{config}->{connect} |
31
|
|
|
|
|
|
|
? Net::NodeTransformator->new( $self->{config}->{connect} ) |
32
|
|
|
|
|
|
|
: Net::NodeTransformator->standalone; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
0
|
|
|
|
$self->{engine} = $config{engine} || $args[0]; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub filter { |
40
|
0
|
|
|
0
|
0
|
|
my ( $self, $text, $args, $conf ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my %config = %$conf; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
my $nnt = |
45
|
|
|
|
|
|
|
$config{connect} |
46
|
|
|
|
|
|
|
? Net::NodeTransformator->new( $config{connect} ) |
47
|
|
|
|
|
|
|
: $self->{nnt}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $engine = $self->{engine}; |
50
|
0
|
|
0
|
|
|
|
$engine ||= shift @$args; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$text = $nnt->transform( $engine, $text, $conf ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |