line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::Ifequal; |
2
|
3
|
|
|
3
|
|
1103
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
68
|
|
3
|
3
|
|
|
3
|
|
12
|
use utf8; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
46
|
|
4
|
3
|
|
|
3
|
|
65
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
83
|
|
5
|
3
|
|
|
3
|
|
14
|
use parent 'DTL::Fast::Tag::If'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{ifequal} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
136
|
use DTL::Fast::Tag::If::Condition; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
43
|
|
10
|
3
|
|
|
3
|
|
698
|
use DTL::Fast::Expression::Operator::Binary::Eq; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
746
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#@Override |
13
|
16
|
|
|
16
|
0
|
41
|
sub get_close_tag { return 'endifequal';} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#@Override |
16
|
|
|
|
|
|
|
sub parse_parameters |
17
|
|
|
|
|
|
|
{ |
18
|
32
|
|
|
32
|
0
|
52
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
32
|
|
|
|
|
57
|
$self->{conditions} = [ ]; |
21
|
32
|
|
|
|
|
100
|
my $sources = $self->parse_sources($self->{parameter}); |
22
|
32
|
|
|
|
|
86
|
return $self->add_main_condition($sources); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#@Override |
26
|
|
|
|
|
|
|
sub parse_tag_chunk |
27
|
|
|
|
|
|
|
{ |
28
|
64
|
|
|
64
|
0
|
174
|
my ( $self, $tag_name, $tag_param, $chunk_lines ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
64
|
|
|
|
|
113
|
my $result = undef; |
31
|
|
|
|
|
|
|
|
32
|
64
|
100
|
|
|
|
123
|
if ($tag_name eq 'else') |
33
|
|
|
|
|
|
|
{ |
34
|
32
|
|
|
|
|
85
|
$self->add_condition(1); |
35
|
32
|
|
|
|
|
49
|
$DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else |
38
|
|
|
|
|
|
|
{ |
39
|
32
|
|
|
|
|
96
|
$result = $self->SUPER::parse_tag_chunk($tag_name, $tag_param, $chunk_lines); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
64
|
|
|
|
|
138
|
return $result; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#@Override |
46
|
|
|
|
|
|
|
sub render |
47
|
|
|
|
|
|
|
{ |
48
|
32
|
|
|
32
|
0
|
51
|
my $self = shift; |
49
|
32
|
|
|
|
|
47
|
my $context = shift; |
50
|
32
|
|
|
|
|
48
|
my $result = ''; |
51
|
|
|
|
|
|
|
|
52
|
32
|
|
|
|
|
47
|
foreach my $condition (@{$self->{conditions}}) |
|
32
|
|
|
|
|
55
|
|
53
|
|
|
|
|
|
|
{ |
54
|
48
|
100
|
|
|
|
118
|
if ($condition->is_true($context)) |
55
|
|
|
|
|
|
|
{ |
56
|
32
|
|
|
|
|
86
|
$result = $condition->render($context); |
57
|
32
|
|
|
|
|
61
|
last; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
32
|
|
|
|
|
107
|
return $result; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub add_main_condition |
64
|
|
|
|
|
|
|
{ |
65
|
16
|
|
|
16
|
0
|
25
|
my $self = shift; |
66
|
16
|
|
|
|
|
23
|
my $sources = shift; |
67
|
16
|
|
|
|
|
25
|
return $self->add_condition(DTL::Fast::Expression::Operator::Binary::Eq->new(@{$sources}[0, 1])); |
|
16
|
|
|
|
|
53
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#@Override |
71
|
|
|
|
|
|
|
sub add_condition |
72
|
|
|
|
|
|
|
{ |
73
|
64
|
|
|
64
|
0
|
95
|
my $self = shift; |
74
|
64
|
|
|
|
|
90
|
my $condition = shift; |
75
|
64
|
|
|
|
|
95
|
push @{$self->{conditions}}, DTL::Fast::Tag::If::Condition->new($condition); |
|
64
|
|
|
|
|
198
|
|
76
|
64
|
|
|
|
|
131
|
return $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |