line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Pro::Extension::IF_TERN; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = "0.11"; |
4
|
0
|
|
|
0
|
0
|
0
|
sub Version { $VERSION; } |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
240
|
|
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 get_filter { |
21
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
22
|
1
|
|
|
|
|
3
|
return _get_filter($self); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
sub _get_filter { |
25
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
26
|
1
|
|
|
|
|
1
|
my @ret ; |
27
|
1
|
|
|
|
|
3
|
push @ret,\&_if_tern; |
28
|
1
|
|
|
|
|
4
|
return @ret; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _if_tern { |
33
|
2
|
|
|
2
|
|
4
|
my $template = shift; |
34
|
2
|
|
|
|
|
2
|
my $re_var = q{\%(\S+?)\?(.*?)(\:(.*?))?\%}; |
35
|
2
|
|
|
|
|
37
|
$$template =~ s{$re_var}{ |
36
|
2
|
|
|
|
|
7
|
my $replace = qq{$2}; |
37
|
2
|
50
|
|
|
|
6
|
if (defined $3) { |
38
|
2
|
|
|
|
|
6
|
$replace .= qq{$4}; |
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
|
|
|
|
0
|
$replace .= q{}; |
41
|
|
|
|
|
|
|
} |
42
|
2
|
|
|
|
|
6
|
$replace; |
43
|
|
|
|
|
|
|
}gse; |
44
|
2
|
|
|
|
|
10
|
return $$template; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |