| 1 | package DTL::Fast::Tag::If; | ||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use strict; use utf8; use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use parent 'DTL::Fast::Tag'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 8 | $DTL::Fast::TAG_HANDLERS{'if'} = __PACKAGE__; | |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use DTL::Fast::Tag::If::Condition; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | #@Override | ||||||||||||||||||||||||||||||||
| 10 | 757 | ▶ | sub get_close_tag{ return 'endif';} | ||||||||||||||||||||||||||||||
|
Subroutine
get_close_tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | #@Override | ||||||||||||||||||||||||||||||||
| 13 | sub parse_parameters | ||||||||||||||||||||||||||||||||
| 14 | { | ||||||||||||||||||||||||||||||||
| 15 | 531 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
parse_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 531 | $self->{'conditions'} = []; | |||||||||||||||||||||||||||||||
| 18 | 531 | $self->add_condition($self->{'parameter'}); | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 526 | return $self; | |||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | #@Override | ||||||||||||||||||||||||||||||||
| 24 | sub add_chunk | ||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||
| 26 | 3448 | ▶ | my( $self, $chunk ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
add_chunk: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 3448 | $self->{'conditions'}->[-1]->add_chunk($chunk); | |||||||||||||||||||||||||||||||
| 29 | 3448 | return $self; | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | #@Override | ||||||||||||||||||||||||||||||||
| 33 | sub parse_tag_chunk | ||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||
| 35 | 1683 | ▶ | my( $self, $tag_name, $tag_param, $chunk_lines ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
parse_tag_chunk: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 1683 | my $result = undef; | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 1683 | ▶ | if( $tag_name eq 'elif' or $tag_name eq 'elsif' ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$tag_name eq "elif" or $tag_name eq "elsif"
MC/DC100%2/2
$tag_name eq "elif" or $tag_name eq "elsif"
$tag_name eq "elif"
$tag_name eq "elsif"
Truth table100%3/3
A or B
A= $tag_name eq "elif"B= $tag_name eq "elsif"
| |||||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||||
| 41 | 420 | $self->add_condition($tag_param); | |||||||||||||||||||||||||||||||
| 42 | 420 | $DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines; | |||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | elsif( $tag_name eq 'else' ) | ||||||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||||||
| 46 | 474 | $self->add_condition(1); | |||||||||||||||||||||||||||||||
| 47 | 474 | $DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines; | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | else | ||||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||||
| 51 | 789 | $result = $self->SUPER::parse_tag_chunk($tag_name, $tag_param, $chunk_lines); | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 1667 | return $result; | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | #@Override | ||||||||||||||||||||||||||||||||
| 58 | sub render | ||||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||||
| 60 | 1786 | ▶ | my( $self, $context ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 1786 | my $result = ''; | |||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 1786 | foreach my $condition (@{$self->{'conditions'}}) | |||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||
| 66 | 2742 | ▶ | if( $condition->is_true($context) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||||||
| 68 | 1774 | $result = $condition->render($context); | |||||||||||||||||||||||||||||||
| 69 | 1770 | last; | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||
| 72 | 1779 | return $result; | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | sub add_condition | ||||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||||
| 77 | 1425 | ▶ | my( $self, $condition ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
add_condition: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 78 | 1425 | push @{$self->{'conditions'}}, DTL::Fast::Tag::If::Condition->new($condition); | |||||||||||||||||||||||||||||||
| 79 | 1420 | return $self; | |||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 8 | 1; | |||||||||||||||||||||||||||||||