line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::If; |
2
|
8
|
|
|
8
|
|
5616
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
8
|
|
|
8
|
|
17
|
|
|
8
|
|
|
8
|
|
263
|
|
|
8
|
|
|
|
|
43
|
|
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
334
|
|
|
8
|
|
|
|
|
205
|
|
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
302
|
|
3
|
8
|
|
|
8
|
|
40
|
use parent 'DTL::Fast::Tag'; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
52
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{'if'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
6077
|
use DTL::Fast::Tag::If::Condition; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
3327
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
757
|
|
|
757
|
0
|
2076
|
sub get_close_tag{ return 'endif';} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#@Override |
13
|
|
|
|
|
|
|
sub parse_parameters |
14
|
|
|
|
|
|
|
{ |
15
|
531
|
|
|
531
|
0
|
666
|
my( $self ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
531
|
|
|
|
|
892
|
$self->{'conditions'} = []; |
18
|
531
|
|
|
|
|
1292
|
$self->add_condition($self->{'parameter'}); |
19
|
|
|
|
|
|
|
|
20
|
526
|
|
|
|
|
968
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#@Override |
24
|
|
|
|
|
|
|
sub add_chunk |
25
|
|
|
|
|
|
|
{ |
26
|
3448
|
|
|
3448
|
0
|
4654
|
my( $self, $chunk ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
3448
|
|
|
|
|
9385
|
$self->{'conditions'}->[-1]->add_chunk($chunk); |
29
|
3448
|
|
|
|
|
7269
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#@Override |
33
|
|
|
|
|
|
|
sub parse_tag_chunk |
34
|
|
|
|
|
|
|
{ |
35
|
1683
|
|
|
1683
|
0
|
3541
|
my( $self, $tag_name, $tag_param, $chunk_lines ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
1683
|
|
|
|
|
2067
|
my $result = undef; |
38
|
|
|
|
|
|
|
|
39
|
1683
|
100
|
100
|
|
|
7728
|
if( $tag_name eq 'elif' or $tag_name eq 'elsif' ) |
|
|
100
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
41
|
420
|
|
|
|
|
788
|
$self->add_condition($tag_param); |
42
|
420
|
|
|
|
|
615
|
$DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif( $tag_name eq 'else' ) |
45
|
|
|
|
|
|
|
{ |
46
|
474
|
|
|
|
|
980
|
$self->add_condition(1); |
47
|
474
|
|
|
|
|
708
|
$DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else |
50
|
|
|
|
|
|
|
{ |
51
|
789
|
|
|
|
|
2052
|
$result = $self->SUPER::parse_tag_chunk($tag_name, $tag_param, $chunk_lines); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1667
|
|
|
|
|
3937
|
return $result; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#@Override |
58
|
|
|
|
|
|
|
sub render |
59
|
|
|
|
|
|
|
{ |
60
|
1786
|
|
|
1786
|
0
|
2675
|
my( $self, $context ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
1786
|
|
|
|
|
2528
|
my $result = ''; |
63
|
|
|
|
|
|
|
|
64
|
1786
|
|
|
|
|
2398
|
foreach my $condition (@{$self->{'conditions'}}) |
|
1786
|
|
|
|
|
3613
|
|
65
|
|
|
|
|
|
|
{ |
66
|
2778
|
100
|
|
|
|
7974
|
if( $condition->is_true($context) ) |
67
|
|
|
|
|
|
|
{ |
68
|
1774
|
|
|
|
|
4917
|
$result = $condition->render($context); |
69
|
1770
|
|
|
|
|
3181
|
last; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
1779
|
|
|
|
|
8341
|
return $result; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub add_condition |
76
|
|
|
|
|
|
|
{ |
77
|
1425
|
|
|
1425
|
0
|
1908
|
my( $self, $condition ) = @_; |
78
|
1425
|
|
|
|
|
1613
|
push @{$self->{'conditions'}}, DTL::Fast::Tag::If::Condition->new($condition); |
|
1425
|
|
|
|
|
4887
|
|
79
|
1420
|
|
|
|
|
2373
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |