line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Extension::IF_TERN; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = "0.24"; |
4
|
0
|
|
|
0
|
0
|
0
|
sub Version { $VERSION; } |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
248
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %fields_parent = |
10
|
|
|
|
|
|
|
( |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub init { |
14
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
15
|
1
|
|
|
|
|
7
|
while (my ($key,$val) = each(%fields_parent)) { |
16
|
0
|
|
0
|
|
|
0
|
$self->{$key} = $self->{$key} || $val; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub push_filter { |
21
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
22
|
1
|
|
|
|
|
2
|
push @{$self->{filter_internal}},@{_get_filter($self)}; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
sub _get_filter { |
25
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
26
|
1
|
|
|
|
|
1
|
my @ret ; |
27
|
1
|
|
|
|
|
5
|
push @ret,\&_if_tern; |
28
|
1
|
|
|
|
|
3
|
return \@ret; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _if_tern { |
33
|
2
|
|
|
2
|
|
307
|
my $template = shift; |
34
|
2
|
|
|
|
|
4
|
my $re_var = q{\%(\S+?)\?(.*?)(\:(.*?))?\%}; |
35
|
2
|
|
|
|
|
56
|
$$template =~ s{$re_var}{ |
36
|
2
|
|
|
|
|
10
|
my $replace = qq{$2}; |
37
|
2
|
50
|
|
|
|
8
|
if (defined $3) { |
38
|
2
|
|
|
|
|
19
|
$replace .= qq{$4}; |
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
|
|
|
|
0
|
$replace .= q{}; |
41
|
|
|
|
|
|
|
} |
42
|
2
|
|
|
|
|
15
|
$replace; |
43
|
|
|
|
|
|
|
}gse; |
44
|
2
|
|
|
|
|
9
|
return $$template; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |