line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::If; |
2
|
8
|
|
|
8
|
|
3509
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
8
|
|
|
8
|
|
13
|
|
|
8
|
|
|
8
|
|
174
|
|
|
8
|
|
|
|
|
27
|
|
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
249
|
|
|
8
|
|
|
|
|
158
|
|
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
250
|
|
3
|
8
|
|
|
8
|
|
25
|
use parent 'DTL::Fast::Tag'; |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{'if'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
3503
|
use DTL::Fast::Tag::If::Condition; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
2221
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
757
|
|
|
757
|
0
|
1364
|
sub get_close_tag{ return 'endif';} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#@Override |
13
|
|
|
|
|
|
|
sub parse_parameters |
14
|
|
|
|
|
|
|
{ |
15
|
531
|
|
|
531
|
0
|
416
|
my( $self ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
531
|
|
|
|
|
701
|
$self->{'conditions'} = []; |
18
|
531
|
|
|
|
|
905
|
$self->add_condition($self->{'parameter'}); |
19
|
|
|
|
|
|
|
|
20
|
526
|
|
|
|
|
585
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#@Override |
24
|
|
|
|
|
|
|
sub add_chunk |
25
|
|
|
|
|
|
|
{ |
26
|
3448
|
|
|
3448
|
0
|
2657
|
my( $self, $chunk ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
3448
|
|
|
|
|
5281
|
$self->{'conditions'}->[-1]->add_chunk($chunk); |
29
|
3448
|
|
|
|
|
3837
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#@Override |
33
|
|
|
|
|
|
|
sub parse_tag_chunk |
34
|
|
|
|
|
|
|
{ |
35
|
1683
|
|
|
1683
|
0
|
2163
|
my( $self, $tag_name, $tag_param, $chunk_lines ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
1683
|
|
|
|
|
1292
|
my $result = undef; |
38
|
|
|
|
|
|
|
|
39
|
1683
|
100
|
100
|
|
|
5785
|
if( $tag_name eq 'elif' or $tag_name eq 'elsif' ) |
|
|
100
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
41
|
420
|
|
|
|
|
511
|
$self->add_condition($tag_param); |
42
|
420
|
|
|
|
|
408
|
$DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif( $tag_name eq 'else' ) |
45
|
|
|
|
|
|
|
{ |
46
|
474
|
|
|
|
|
601
|
$self->add_condition(1); |
47
|
474
|
|
|
|
|
436
|
$DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else |
50
|
|
|
|
|
|
|
{ |
51
|
789
|
|
|
|
|
1425
|
$result = $self->SUPER::parse_tag_chunk($tag_name, $tag_param, $chunk_lines); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1667
|
|
|
|
|
2243
|
return $result; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#@Override |
58
|
|
|
|
|
|
|
sub render |
59
|
|
|
|
|
|
|
{ |
60
|
1786
|
|
|
1786
|
0
|
1517
|
my( $self, $context ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
1786
|
|
|
|
|
1433
|
my $result = ''; |
63
|
|
|
|
|
|
|
|
64
|
1786
|
|
|
|
|
1224
|
foreach my $condition (@{$self->{'conditions'}}) |
|
1786
|
|
|
|
|
2153
|
|
65
|
|
|
|
|
|
|
{ |
66
|
2734
|
100
|
|
|
|
4995
|
if( $condition->is_true($context) ) |
67
|
|
|
|
|
|
|
{ |
68
|
1774
|
|
|
|
|
3604
|
$result = $condition->render($context); |
69
|
1770
|
|
|
|
|
1910
|
last; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
1779
|
|
|
|
|
4781
|
return $result; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub add_condition |
76
|
|
|
|
|
|
|
{ |
77
|
1425
|
|
|
1425
|
0
|
1280
|
my( $self, $condition ) = @_; |
78
|
1425
|
|
|
|
|
942
|
push @{$self->{'conditions'}}, DTL::Fast::Tag::If::Condition->new($condition); |
|
1425
|
|
|
|
|
3263
|
|
79
|
1420
|
|
|
|
|
1214
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |