line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Replacer; |
2
|
98
|
|
|
98
|
|
32887
|
use strict; |
|
98
|
|
|
|
|
830
|
|
|
98
|
|
|
|
|
2896
|
|
3
|
98
|
|
|
98
|
|
412
|
use utf8; |
|
98
|
|
|
|
|
878
|
|
|
98
|
|
|
|
|
1643
|
|
4
|
98
|
|
|
98
|
|
1966
|
use warnings FATAL => 'all'; |
|
98
|
|
|
|
|
195
|
|
|
98
|
|
|
|
|
3417
|
|
5
|
98
|
|
|
98
|
|
444
|
use parent 'DTL::Fast::Entity'; |
|
98
|
|
|
|
|
175
|
|
|
98
|
|
|
|
|
559
|
|
6
|
|
|
|
|
|
|
|
7
|
98
|
|
|
98
|
|
33530
|
use DTL::Fast::Replacer::Replacement; |
|
98
|
|
|
|
|
226
|
|
|
98
|
|
|
|
|
2320
|
|
8
|
98
|
|
|
98
|
|
29460
|
use DTL::Fast::Variable; |
|
98
|
|
|
|
|
277
|
|
|
98
|
|
|
|
|
50663
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub backup_strings |
13
|
|
|
|
|
|
|
{ |
14
|
1086
|
|
|
1086
|
0
|
2174
|
my ( $self, $expression ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$self->clean_replacement($expression) |
17
|
|
|
|
|
|
|
if (not $self->{replacement} |
18
|
1086
|
100
|
66
|
|
|
5524
|
or not $self->{replacement}->isa('DTL::Fast::Replacer::Replacement')); |
19
|
|
|
|
|
|
|
|
20
|
1086
|
|
|
|
|
3204
|
$expression =~ s/(?backup_value($1.$2.$1)/ge; |
|
214
|
|
|
|
|
1085
|
|
21
|
|
|
|
|
|
|
|
22
|
1086
|
|
|
|
|
4249
|
return $expression; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub backup_value |
26
|
|
|
|
|
|
|
{ |
27
|
214
|
|
|
214
|
0
|
454
|
my ( $self, $value ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $self->{replacement}->add_replacement( |
30
|
214
|
|
|
|
|
804
|
DTL::Fast::Variable->new($value) |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub backup_expression |
35
|
|
|
|
|
|
|
{ |
36
|
11
|
|
|
11
|
0
|
33
|
my ( $self, $expression ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $self->{replacement}->add_replacement( |
39
|
|
|
|
|
|
|
DTL::Fast::Expression->new( |
40
|
|
|
|
|
|
|
$expression |
41
|
|
|
|
|
|
|
, replacement => $self->{replacement} |
42
|
11
|
|
|
|
|
46
|
, level => 0 |
43
|
|
|
|
|
|
|
) |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_backup |
48
|
|
|
|
|
|
|
{ |
49
|
1303
|
|
|
1303
|
0
|
3842
|
return shift->{replacement}->get_replacement(shift); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_backup_or_variable |
54
|
|
|
|
|
|
|
{ |
55
|
974
|
|
|
974
|
0
|
1958
|
my ( $self, $token ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $result = $self->get_backup($token) |
58
|
974
|
|
66
|
|
|
2190
|
// DTL::Fast::Variable->new( $token, replacement => $self->{replacement} ); |
59
|
|
|
|
|
|
|
|
60
|
972
|
|
|
|
|
3392
|
return $result; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub get_backup_or_expression |
64
|
|
|
|
|
|
|
{ |
65
|
329
|
|
|
329
|
0
|
701
|
my ( $self, $token, $current_level ) = @_; |
66
|
329
|
|
50
|
|
|
735
|
$current_level //= - 1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $result = $self->get_backup($token) |
69
|
|
|
|
|
|
|
// DTL::Fast::Expression->new( |
70
|
|
|
|
|
|
|
$token |
71
|
|
|
|
|
|
|
, replacement => $self->{replacement} |
72
|
329
|
|
66
|
|
|
1068
|
, level => $current_level + 1 |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
325
|
|
|
|
|
1345
|
return $result; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub clean_replacement |
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
return shift->set_replacement( |
81
|
713
|
|
|
713
|
0
|
3059
|
DTL::Fast::Replacer::Replacement->new(shift) |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub set_replacement |
86
|
|
|
|
|
|
|
{ |
87
|
713
|
|
|
713
|
0
|
1462
|
my ( $self, $replacement ) = @_; |
88
|
713
|
|
|
|
|
1344
|
$self->{replacement} = $replacement; |
89
|
713
|
|
|
|
|
1143
|
return $self; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub parse_sources |
93
|
|
|
|
|
|
|
{ |
94
|
95
|
|
|
95
|
0
|
189
|
my ( $self, $source ) = @_; |
95
|
|
|
|
|
|
|
|
96
|
95
|
|
|
|
|
257
|
my $sources = $self->backup_strings($source); |
97
|
|
|
|
|
|
|
|
98
|
95
|
100
|
|
|
|
293
|
warn $self->get_parse_warning( |
99
|
|
|
|
|
|
|
sprintf( |
100
|
|
|
|
|
|
|
"comma-separated source values in %s tag are DEPRICATED, please use spaces:\n\t%s" |
101
|
|
|
|
|
|
|
, ref $self |
102
|
|
|
|
|
|
|
, $source |
103
|
|
|
|
|
|
|
) |
104
|
|
|
|
|
|
|
) if ($sources =~ /,/); |
105
|
|
|
|
|
|
|
|
106
|
95
|
|
|
|
|
184
|
my $result = [ ]; |
107
|
|
|
|
|
|
|
|
108
|
95
|
|
|
|
|
449
|
foreach my $source (split /[,\s]+/, $sources) |
109
|
|
|
|
|
|
|
{ |
110
|
312
|
50
|
|
|
|
661
|
if ($source =~ /^(__BLOCK_.+?)\|(.+)$/) # filtered static variable |
111
|
|
|
|
|
|
|
{ |
112
|
0
|
|
|
|
|
0
|
push @$result, $self->get_backup_or_variable($1); |
113
|
0
|
|
|
|
|
0
|
$result->[- 1]->{filter_manager}->parse_filters($2); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
else |
116
|
|
|
|
|
|
|
{ |
117
|
312
|
|
|
|
|
703
|
push @$result, $self->get_backup_or_variable($source) |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
95
|
|
|
|
|
261
|
return $result; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |