| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DTL::Fast::FilterManager; |
|
2
|
98
|
|
|
98
|
|
303
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
|
98
|
|
|
98
|
|
88
|
|
|
|
98
|
|
|
98
|
|
2427
|
|
|
|
98
|
|
|
|
|
313
|
|
|
|
98
|
|
|
|
|
85
|
|
|
|
98
|
|
|
|
|
336
|
|
|
|
98
|
|
|
|
|
1751
|
|
|
|
98
|
|
|
|
|
101
|
|
|
|
98
|
|
|
|
|
2803
|
|
|
3
|
98
|
|
|
98
|
|
335
|
use parent 'DTL::Fast::Replacer'; |
|
|
98
|
|
|
|
|
102
|
|
|
|
98
|
|
|
|
|
331
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
98
|
|
|
98
|
|
5982
|
use DTL::Fast::Template; |
|
|
98
|
|
|
|
|
105
|
|
|
|
98
|
|
|
|
|
2345
|
|
|
6
|
98
|
|
|
98
|
|
321
|
use Scalar::Util qw(weaken); |
|
|
98
|
|
|
|
|
114
|
|
|
|
98
|
|
|
|
|
51398
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new |
|
9
|
|
|
|
|
|
|
{ |
|
10
|
1776
|
|
|
1776
|
0
|
3311
|
my( $proto, %kwargs ) = @_; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1776
|
|
33
|
|
|
4577
|
$proto = ref $proto || $proto; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $self = $proto->SUPER::new( |
|
15
|
|
|
|
|
|
|
'filters' => [], |
|
16
|
|
|
|
|
|
|
'filters_number' => 0, |
|
17
|
1776
|
|
|
|
|
4775
|
'replacement' => $kwargs{'replacement'}, # if strings were back-uped before |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
1776
|
100
|
|
|
|
3384
|
if( $self->{'replacement'} ) |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
784
|
|
|
|
|
1350
|
weaken($self->{'replacement'}); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
1776
|
100
|
|
|
|
2774
|
if( $kwargs{'filters'} ) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
4
|
50
|
|
|
|
6
|
if( ref $kwargs{'filters'} eq 'ARRAY' ) |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
0
|
|
|
|
|
0
|
$self->add_filters($kwargs{'filters'}); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
else |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
4
|
|
|
|
|
6
|
$self->parse_filters($kwargs{'filters'}); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
1776
|
|
|
|
|
4394
|
return $self; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub filter |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
470
|
|
|
470
|
0
|
460
|
my $self = shift; |
|
43
|
470
|
|
|
|
|
450
|
my $value = shift; |
|
44
|
470
|
|
|
|
|
367
|
my $context = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
470
|
|
|
|
|
519
|
$self->{'safe'} = 0; |
|
47
|
|
|
|
|
|
|
|
|
48
|
470
|
|
|
|
|
384
|
foreach my $filter (@{$self->{'filters'}}) |
|
|
470
|
|
|
|
|
693
|
|
|
49
|
|
|
|
|
|
|
{ |
|
50
|
515
|
50
|
|
|
|
1572
|
$value = $filter->filter($self, $value, $context) |
|
51
|
|
|
|
|
|
|
if defined $filter; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
464
|
|
|
|
|
1543
|
return $value; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub parse_filters |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
4
|
|
|
4
|
0
|
5
|
my $self = shift; |
|
60
|
4
|
|
|
|
|
5
|
my $filter_string = shift; |
|
61
|
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
10
|
$filter_string =~ s/(^\s+|\s+$)//gsi; |
|
63
|
4
|
|
|
|
|
17
|
return $self->add_filters([split /\s*\|+\s*/x, $filter_string]); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub add_filters |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
467
|
|
|
467
|
0
|
488
|
my $self = shift; |
|
69
|
467
|
|
|
|
|
409
|
my $filter_names = shift; |
|
70
|
|
|
|
|
|
|
|
|
71
|
467
|
|
|
|
|
734
|
foreach my $filter_name (@$filter_names) |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
514
|
|
|
|
|
903
|
$self->add_filter($filter_name); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
466
|
|
|
|
|
753
|
return $self; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub add_filter |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
515
|
|
|
515
|
0
|
439
|
my $self = shift; |
|
81
|
515
|
|
|
|
|
509
|
my $filter_name = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
515
|
|
|
|
|
1951
|
my @arguments = split /\s*\:\s*/x, $self->backup_strings($filter_name); |
|
84
|
515
|
|
|
|
|
702
|
$filter_name = shift @arguments; |
|
85
|
|
|
|
|
|
|
|
|
86
|
515
|
100
|
66
|
|
|
1529
|
if( |
|
87
|
|
|
|
|
|
|
not exists $DTL::Fast::FILTER_HANDLERS{$filter_name} |
|
88
|
|
|
|
|
|
|
and exists $DTL::Fast::KNOWN_FILTERS{$filter_name} |
|
89
|
|
|
|
|
|
|
) |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
85
|
|
|
|
|
32257
|
require Module::Load; |
|
92
|
85
|
|
|
|
|
47941
|
Module::Load::load($DTL::Fast::KNOWN_FILTERS{$filter_name}); |
|
93
|
85
|
|
|
|
|
887
|
$DTL::Fast::LOADED_MODULES{$DTL::Fast::KNOWN_FILTERS{$filter_name}} = time; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
515
|
100
|
|
|
|
908
|
if( exists $DTL::Fast::FILTER_HANDLERS{$filter_name} ) |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
513
|
|
|
|
|
630
|
my $args = []; |
|
99
|
|
|
|
|
|
|
|
|
100
|
513
|
|
|
|
|
757
|
foreach my $argument (@arguments) |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
353
|
|
33
|
|
|
1066
|
push @$args, $self->get_backup_or_variable($argument) // $argument; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
513
|
|
|
|
|
480
|
push @{$self->{'filters'}}, $DTL::Fast::FILTER_HANDLERS{$filter_name}->new($args); |
|
|
513
|
|
|
|
|
2109
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
512
|
|
|
|
|
765
|
$self->{'filters_number'}++; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
else |
|
110
|
|
|
|
|
|
|
{ |
|
111
|
2
|
|
|
|
|
18
|
warn $self->get_parse_error( "unknown filter $filter_name" ); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
514
|
|
|
|
|
933
|
return $self; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |