line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Compiled::Filter; |
2
|
|
|
|
|
|
|
our $VERSION = '1.003'; # VERSION |
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
60
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
30
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use constant SUBS => 0; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
307
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
118
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
158
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
110
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my ($class, $spec) = @_; |
10
|
0
|
0
|
|
|
|
|
if (ref $spec eq __PACKAGE__) { |
11
|
0
|
|
|
|
|
|
return $spec; |
12
|
|
|
|
|
|
|
} |
13
|
0
|
|
|
|
|
|
my $self = []; |
14
|
0
|
|
|
|
|
|
bless $self, $class; |
15
|
0
|
|
|
|
|
|
$self->init($spec); |
16
|
0
|
|
|
|
|
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init { |
20
|
0
|
|
|
0
|
0
|
|
my ($self, $spec) = @_; |
21
|
0
|
0
|
|
|
|
|
if (ref $spec eq 'CODE') { |
22
|
0
|
|
|
|
|
|
$self->[SUBS] = [ |
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
code => $spec, |
25
|
|
|
|
|
|
|
format => 'scalar', |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
0
|
0
|
|
|
|
|
for my $filter (ref $spec eq 'ARRAY' ? @$spec : $spec) { |
31
|
0
|
|
|
|
|
|
push @{ $self->[SUBS] }, { |
32
|
|
|
|
|
|
|
format => $filter->{format} || 'scalar', |
33
|
0
|
|
0
|
|
|
|
code => $filter->{'sub'}, |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub filter { |
40
|
|
|
|
|
|
|
my ($self, $data) = @_; |
41
|
|
|
|
|
|
|
for my $filter (@{ $self->[SUBS] }) { |
42
|
|
|
|
|
|
|
if ($filter->{format} eq 'scalar') { |
43
|
|
|
|
|
|
|
$filter->{code}->(\$data); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
|
|
|
|
|
|
my $lines = [split /(?:\n)/, $data]; |
47
|
|
|
|
|
|
|
$filter->{code}->($lines); |
48
|
|
|
|
|
|
|
$data = join '', @$lines; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
# inplace edit |
52
|
|
|
|
|
|
|
$_[1] = $data; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
__END__ |