| 1 | package Template::Alloy::TT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Template::Alloy::TT - Template::Toolkit role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use Template::Alloy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use Template::Alloy::Operator qw($QR_OP_ASSIGN); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | our $VERSION = $Template::Alloy::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 7 | our $QR_COMMENTS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use constant posessive => ($^V >= 5.009) || 0; # perl 5.10 allows possessive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$^V >= 5.009 || 0
MC/DC0%0/1
$^V >= 5.009 || 0
$^V >= 5.009
Truth table50%1/2
A
A= $^V >= 5.009
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub new { die "This class is a role for use by packages such as Template::Alloy" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4209 | ▶ | sub parse_tree_tt3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_tree_tt3: called CC=116 SCAR=50.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4209 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4209 | my $str_ref = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4209 | ▶ | my $one_tag_only = shift() ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4209 | ▶ | if (! $str_ref || ! defined $$str_ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$str_ref and defined $$str_ref
MC/DC0%0/2
$str_ref and defined $$str_ref
$str_ref
defined $$str_ref
Truth table33%1/3
A and B
A= $str_refB= defined $$str_ref
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $self->throw('parse.no_string', "No string or undefined during parse", undef, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4209 | ▶ | my $STYLE = $self->{'TAG_STYLE'} || 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'TAG_STYLE'} || 'default'
MC/DC100%1/1
$self->{'TAG_STYLE'} || 'default'
$self->{'TAG_STYLE'}
Truth table100%2/2
A
A= $self->{'TAG_STYLE'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4209 | ▶ | local $self->{'_end_tag'} = $self->{'END_TAG'} || $Template::Alloy::Parse::TAGS->{$STYLE}->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'END_TAG'} || $Template::Alloy::Parse::TAGS->{$STYLE}[1]
MC/DC0%0/2
$self->{'END_TAG'} || $Template::Alloy::Parse::TAGS->{$STYLE}[1]
$self->{'END_TAG'}
$Template::Alloy::Parse::TAGS->{$STYLE}[1]
Truth table66%2/3
A || B
A= $self->{'END_TAG'}B= $Template::Alloy::Parse::TAGS->{$STYLE}[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4209 | ▶ | local $self->{'START_TAG'} = $self->{'START_TAG'} || $Template::Alloy::Parse::TAGS->{$STYLE}->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'START_TAG'} || $Template::Alloy::Parse::TAGS->{$STYLE}[0]
MC/DC0%0/2
$self->{'START_TAG'} || $Template::Alloy::Parse::TAGS->{$STYLE}[0]
$self->{'START_TAG'}
$Template::Alloy::Parse::TAGS->{$STYLE}[0]
Truth table66%2/3
A || B
A= $self->{'START_TAG'}B= $Template::Alloy::Parse::TAGS->{$STYLE}[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4209 | ▶ | local $self->{'_start_tag'} = (! $self->{'INTERPOLATE'}) ? $self->{'START_TAG'} : qr{(?: $self->{'START_TAG'} | (\$))}sx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4209 | ▶ | local $QR_COMMENTS = $QR_COMMENTS || (posessive() ? (local $Template::Alloy::Parse::QR_COMMENTS = "(?sm: \\s*+ \\# .*? (?: \$ | (?=$self->{'_end_tag'}) ) )*+ \\s*+") : $Template::Alloy::Parse::QR_COMMENTS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$Template::Alloy::TT::QR_COMMENTS || (local $Template::Alloy::Parse::QR_COMMENTS = "(?sm: \\s*+ \\# .*? (?: \$ | (?=$self->{'_end_tag'}) ) )*+ \\s*+")
MC/DC100%1/1
$Template::Alloy::TT::QR_COMMENTS || (local $Template::Alloy::Parse::QR_COMMENTS = "(?sm: \\s*+ \\# .*? (?: \$ | (?=$self->{'_end_tag'}) ) )*+ \\s*+")
$Template::Alloy::TT::QR_COMMENTS
Truth table100%2/2
A
A= $Template::Alloy::TT::QR_COMMENTS
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4209 | my $dirs = $Template::Alloy::Parse::DIRECTIVES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4209 | my $aliases = $Template::Alloy::Parse::ALIASES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4209 | local @{ $dirs }{ keys %$aliases } = values %$aliases; # temporarily add to the table | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4209 | local @{ $self }{@Template::Alloy::CONFIG_COMPILETIME} = @{ $self }{@Template::Alloy::CONFIG_COMPILETIME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4209 | ▶ | delete $dirs->{'JS'} if ! $self->{'COMPILE_JS'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4209 | my @tree; # the parsed tree | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4209 | my $pointer = \@tree; # pointer to current tree to handle nested blocks | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 4209 | my @state; # maintain block levels | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 4209 | local $self->{'_state'} = \@state; # allow for items to introspect (usually BLOCKS) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 4209 | local $self->{'_no_interp'} = 0; # no interpolation in some blocks (usually PERL) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 4209 | my @in_view; # let us know if we are in a view | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | my @blocks; # store blocks for later moving to front | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4209 | my @meta; # place to store any found meta information (to go into META) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 4209 | my $post_chomp = 0; # previous post_chomp setting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 4209 | my $continue = 0; # flag for multiple directives in the same tag | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4209 | my $post_op = 0; # found a post-operative DIRECTIVE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4209 | my $capture; # flag to start capture | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | my $func; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4209 | my $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4209 | ▶ | pos($$str_ref) = 0 if ! $one_tag_only; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4209 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ### continue looking for information in a semi-colon delimited tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 13083 | ▶ | if ($continue) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1742 | $node = [undef, $continue, undef]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } elsif ($one_tag_only) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 27 | $node = [undef, pos($$str_ref), undef]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ### find the next opening tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 11314 | ▶ | $$str_ref =~ m{ \G (.*?) $self->{'_start_tag'} }gcxs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | || last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 7217 | my ($text, $dollar) = ($1, $2); # dollar is set only on an interpolated var | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ### found a text portion - chomp it and store it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 7217 | ▶ | if (length $text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1779 | ▶ | if (! $post_chomp) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | elsif ($post_chomp == 1) { $text =~ s{ ^ [^\S\n]* \n }{}x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | elsif ($post_chomp == 2) { $text =~ s{ ^ \s+ }{ }x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 90 | elsif ($post_chomp == 3) { $text =~ s{ ^ \s+ }{}x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1779 | ▶ | push @$pointer, $text if length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ### handle variable interpolation ($2 eq $) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 7217 | ▶ | if ($dollar) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ### inspect previous text chunk for escape slashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 107 | ▶ | my $n = ($text =~ m{ (\\+) $ }x) ? length($1) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 107 | ▶ | if ($self->{'_no_interp'} || $n % 2) { # were there odd escapes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"_no_interp"} or $n % 2
MC/DC100%2/2
$self->{"_no_interp"} or $n % 2
$self->{"_no_interp"}
$n % 2
Truth table100%3/3
A or B
A= $self->{"_no_interp"}B= $n % 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 18 | my $prev_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 18 | ▶ | $prev_text = \$pointer->[-1] if defined($pointer->[-1]) && ! ref($pointer->[-1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $pointer->[-1] and not ref $pointer->[-1]
MC/DC0%0/2
defined $pointer->[-1] and not ref $pointer->[-1]
defined $pointer->[-1]
not ref $pointer->[-1]
Truth table33%1/3
A and not(B)
A= defined $pointer->[-1]B= not ref $pointer->[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 18 | ▶ | chop($$prev_text) if $n % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ($prev_text) { $$prev_text .= $dollar } else { push @$pointer, $dollar } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 89 | my $not = $$str_ref =~ m{ \G ! }gcx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 89 | my $mark = pos($$str_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 89 | my $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 89 | ▶ | if ($$str_ref =~ m{ \G \{ }gcx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 37 | local $self->{'_operator_precedence'} = 0; # allow operators | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 37 | $ref = $self->parse_expr($str_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 37 | ▶ | $$str_ref =~ m{ \G \s* $QR_COMMENTS \} }gcx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | || $self->throw('parse', 'Missing close }', undef, pos($$str_ref)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 52 | local $self->{'_operator_precedence'} = 1; # no operators | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 52 | local $QR_COMMENTS = local $Template::Alloy::Parse::QR_COMMENTS = qr{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 52 | $ref = $self->parse_expr($str_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 89 | ▶ | $self->throw('parse', "Error while parsing for interpolated string", undef, pos($$str_ref)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | if ! defined $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 89 | ▶ | if (! $not && $self->{'SHOW_UNDEFINED_INTERP'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $not and $self->{"SHOW_UNDEFINED_INTERP"}
MC/DC100%2/2
not $not and $self->{"SHOW_UNDEFINED_INTERP"}
not $not
$self->{"SHOW_UNDEFINED_INTERP"}
Truth table100%3/3
not(A) and B
A= not $notB= $self->{"SHOW_UNDEFINED_INTERP"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 12 | $ref = [[undef, '//', $ref, '$'.substr($$str_ref, $mark, pos($$str_ref)-$mark)], 0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 89 | push @$pointer, ['GET', $mark, pos($$str_ref), $ref]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 89 | $post_chomp = 0; # no chomping after dollar vars | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 89 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 7110 | $node = [undef, pos($$str_ref), undef]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ### take care of whitespace and comments flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 7110 | ▶ | my $pre_chomp = $$str_ref =~ m{ \G ([+=~-]) }gcx ? $1 : $self->{'PRE_CHOMP'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 7110 | ▶ | $pre_chomp =~ y/-=~+/1230/ if $pre_chomp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 7110 | ▶ | if ($pre_chomp && $pointer->[-1] && ! ref $pointer->[-1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$pre_chomp and $pointer->[-1] and not ref $pointer->[-1]
$pre_chomp and $pointer->[-1]
MC/DC100%3/3
$pre_chomp and $pointer->[-1] and not ref $pointer->[-1]
$pre_chomp
$pointer->[-1]
not ref $pointer->[-1]
Truth table100%4/4
A and B and not(C)
A= $pre_chompB= $pointer->[-1]C= not ref $pointer->[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 65 | ▶ | if ($pre_chomp == 1) { $pointer->[-1] =~ s{ (?:\n|^) [^\S\n]* \z }{}x } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | elsif ($pre_chomp == 2) { $pointer->[-1] =~ s{ (\s+) \z }{ }x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 30 | elsif ($pre_chomp == 3) { $pointer->[-1] =~ s{ (\s+) \z }{}x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 65 | ▶ | splice(@$pointer, -1, 1, ()) if ! length $pointer->[-1]; # remove the node if it is zero length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ### leading # means to comment the entire section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 7110 | ▶ | if ($$str_ref =~ m{ \G \# }gcx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 21 | ▶ | $$str_ref =~ m{ \G (.*?) ([+~=-]?) ($self->{'_end_tag'}) }gcxs # brute force - can't comment tags with nested %] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | || $self->throw('parse', "Missing closing tag", undef, pos($$str_ref)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 21 | $node->[0] = '#'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 21 | $node->[2] = pos($$str_ref) - length($3) - length($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 21 | push @$pointer, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 21 | $post_chomp = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 21 | ▶ | $post_chomp ||= $self->{'POST_CHOMP'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$post_chomp ||= $self->{"POST_CHOMP"}
MC/DC0%0/2
$post_chomp ||= $self->{"POST_CHOMP"}
$post_chomp
$self->{"POST_CHOMP"}
Truth table33%1/3
A ||= B
A= $post_chompB= $self->{"POST_CHOMP"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 21 | ▶ | $post_chomp =~ y/-=~+/1230/ if $post_chomp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 21 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | #$$str_ref =~ m{ \G \s* $QR_COMMENTS }gcxo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ### look for DIRECTIVES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 8858 | ▶ | if ($$str_ref =~ m{ \G \s* $QR_COMMENTS $Template::Alloy::Parse::QR_DIRECTIVE }gcxo # find a word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition72%8/11
$$str_ref =~ / \G \s* $Template::Alloy::TT::QR_COMMENTS $Template::Alloy::Parse::QR_DIRECTIVE /cgox and $func = $self->{"ANYCASE"} ? uc $1 : $1 and $dirs->{$func} || (pos $$str_ref -= length $1) && 0
$$str_ref =~ / \G \s* $Template::Alloy::TT::QR_COMMENTS $Template::Alloy::Parse::QR_DIRECTIVE /cgox and $func = $self->{"ANYCASE"} ? uc $1 : $1
$dirs->{$func} or pos $$str_ref -= length $1 and 0
pos $$str_ref -= length $1 and 0
MC/DC25%1/4
$$str_ref =~ / \G \s* $Template::Alloy::TT::QR_COMMENTS $Template::Alloy::Parse::QR_DIRECTIVE /cgox and $func = $self->{"ANYCASE"} ? uc $1 : $1 and $dirs->{$func} || (pos $$str_ref -= length $1) && 0
$$str_ref =~ / \G \s* $Template::Alloy::TT::QR_COMMENTS $Template::Alloy::Parse::QR_DIRECTIVE /cgox
$func = $self->{"ANYCASE"} ? uc $1 : $1
$dirs->{$func}
pos $$str_ref -= length $1
Truth table60%3/5
A and B and C or D
A= $$str_ref =~ / \G \s* $Template::Alloy::TT::QR_COMMENTS $Template::Alloy::Parse::QR_DIRECTIVE /cgoxB= $func = $self->{"ANYCASE"} ? uc $1 : $1C= $dirs->{$func}D= pos $$str_ref -= length $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | && ($func = $self->{'ANYCASE'} ? uc($1) : $1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | && ($dirs->{$func} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | || ((pos($$str_ref) -= length $1) && 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ) { # is it a directive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 3938 | $$str_ref =~ m{ \G \s* $QR_COMMENTS }gcx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3938 | ▶ | $func = $aliases->{$func} if $aliases->{$func}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 3938 | $node->[0] = $func; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ### store out this current node level to the appropriate tree location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # on a post operator - replace the original node with the new one - store the old in the new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 3938 | ▶ | if ($dirs->{$func}->[3] && $post_op) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$dirs->{$func}[3] and $post_op
MC/DC100%2/2
$dirs->{$func}[3] and $post_op
$dirs->{$func}[3]
$post_op
Truth table100%3/3
A and B
A= $dirs->{$func}[3]B= $post_op
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 150 | my @post_op = @$post_op; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 150 | @$post_op = @$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 150 | $node = $post_op; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 150 | $node->[4] = [\@post_op]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # if there was not a semi-colon - see if semis were required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ▶ | } elsif ($post_op && $self->{'SEMICOLONS'}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$post_op and $self->{"SEMICOLONS"}
MC/DC100%2/2
$post_op and $self->{"SEMICOLONS"}
$post_op
$self->{"SEMICOLONS"}
Truth table100%3/3
A and B
A= $post_opB= $self->{"SEMICOLONS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | $self->throw('parse', "Missing semi-colon with SEMICOLONS => 1", undef, $node->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # handle directive captures for an item like "SET foo = BLOCK" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } elsif ($capture) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 136 | push @{ $capture->[4] }, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 136 | undef $capture; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # normal nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3649 | push @$pointer, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ### parse any remaining tag details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3935 | $node->[3] = eval { $dirs->{$func}->[0]->($self, $str_ref, $node) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3935 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 27 | ▶ | $err->node($node) if UNIVERSAL::can($err, 'node') && ! $err->node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
UNIVERSAL::can($err, "node") and not $err->node
MC/DC0%0/2
UNIVERSAL::can($err, "node") and not $err->node
UNIVERSAL::can($err, "node")
not $err->node
Truth table33%1/3
A and not(B)
A= UNIVERSAL::can($err, "node")B= not $err->node
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 27 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 3908 | $node->[2] = pos $$str_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ### anything that behaves as a block ending | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3908 | ▶ | if ($func eq 'END' || $dirs->{$func}->[4]) { # [4] means it is a continuation block (ELSE, CATCH, etc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
$func eq "END" or $dirs->{$func}[4]
MC/DC100%2/2
$func eq "END" or $dirs->{$func}[4]
$func eq "END"
$dirs->{$func}[4]
Truth table100%3/3
A or B
A= $func eq "END"B= $dirs->{$func}[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1077 | ▶ | if (! @state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 9 | $self->throw('parse', "Found an $func tag while not in a block", $node, pos($$str_ref)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1068 | my $parent_node = pop @state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1068 | ▶ | if ($func ne 'END') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 209 | pop @$pointer; # we will store the node in the parent instead | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 209 | $parent_node->[5] = $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 209 | my $parent_type = $parent_node->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 209 | ▶ | if (! $dirs->{$func}->[4]->{$parent_type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | $self->throw('parse', "Found unmatched nested block", $node, pos($$str_ref)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ### restore the pointer up one level (because we hit the end of a block) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1065 | ▶ | $pointer = (! @state) ? \@tree : $state[-1]->[4]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ### normal end block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1065 | ▶ | if ($func eq 'END') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 859 | ▶ | if ($parent_node->[0] eq 'BLOCK') { # move BLOCKS to front | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 305 | ▶ | if (defined($parent_node->[3]) && @in_view) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $parent_node->[3] and @in_view
MC/DC0%0/2
defined $parent_node->[3] and @in_view
defined $parent_node->[3]
@in_view
Truth table33%1/3
A and B
A= defined $parent_node->[3]B= @in_view
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | push @{ $in_view[-1] }, $parent_node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 305 | ▶ | push @blocks, $parent_node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | if length $parent_node->[3]; # macro blocks may not have a name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 305 | ▶ | if ($pointer->[-1] && ! $pointer->[-1]->[6]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pointer->[-1] and not $pointer->[-1][6]
MC/DC50%1/2
$pointer->[-1] and not $pointer->[-1][6]
$pointer->[-1]
not $pointer->[-1][6]
Truth table66%2/3
A and not(B)
A= $pointer->[-1]B= not $pointer->[-1][6]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 252 | splice(@$pointer, -1, 1, ()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } elsif ($parent_node->[0] eq 'VIEW') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $ref = { map {($_->[3] => $_->[4])} @{ pop @in_view }}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | unshift @{ $parent_node->[3] }, $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } elsif ($dirs->{$parent_node->[0]}->[5]) { # allow no_interp to turn on and off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 21 | $self->{'_no_interp'}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ### continuation block - such as an elsif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 206 | push @state, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 206 | ▶ | $pointer = $node->[4] ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$node->[4] ||= []
MC/DC0%0/1
$node->[4] ||= []
$node->[4]
Truth table50%1/2
A
A= $node->[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ### handle block directives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ▶ | } elsif ($dirs->{$func}->[2] && ! $post_op) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$dirs->{$func}[2] and not $post_op
MC/DC100%2/2
$dirs->{$func}[2] and not $post_op
$dirs->{$func}[2]
not $post_op
Truth table100%3/3
A and not(B)
A= $dirs->{$func}[2]B= not $post_op
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 877 | push @state, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 877 | ▶ | $pointer = $node->[4] ||= []; # allow future parsed nodes before END tag to end up in current node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$node->[4] ||= []
MC/DC0%0/1
$node->[4] ||= []
$node->[4]
Truth table50%1/2
A
A= $node->[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 877 | ▶ | push @in_view, [] if $func eq 'VIEW'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 877 | ▶ | $self->{'_no_interp'}++ if $dirs->{$node->[0]}->[5] # allow no_interp to turn on and off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } elsif ($func eq 'TAGS') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 75 | ($self->{'_start_tag'}, $self->{'_end_tag'}, my $old_end) = (@{ $node->[3] }[0,1], $self->{'_end_tag'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | ### allow for one more closing tag of the old style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 75 | ▶ | if ($$str_ref =~ m{ \G \s* $QR_COMMENTS ([+~=-]?) $old_end }gcxs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 66 | $Template::Alloy::Parse::QR_COMMENTS = "(?sm: \\s*+ \\# .*? (?: \$ | (?=$self->{'_end_tag'}) ) )*+ \\s*+" if posessive(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 66 | $QR_COMMENTS = $Template::Alloy::Parse::QR_COMMENTS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 66 | ▶ | $post_chomp = $1 || $self->{'POST_CHOMP'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$1 || $self->{'POST_CHOMP'}
MC/DC0%0/2
$1 || $self->{'POST_CHOMP'}
$1
$self->{'POST_CHOMP'}
Truth table33%1/3
A || B
A= $1B= $self->{'POST_CHOMP'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 66 | ▶ | $post_chomp =~ y/-=~+/1230/ if $post_chomp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 66 | $continue = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 66 | $post_op = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 66 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 9 | $Template::Alloy::Parse::QR_COMMENTS = "(?sm: \\s*+ \\# .*? (?: \$ | (?=$self->{'_end_tag'}) ) )*+ \\s*+" if posessive(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 9 | $QR_COMMENTS = $Template::Alloy::Parse::QR_COMMENTS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } elsif ($func eq 'META') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 134 | unshift @meta, @{ $node->[3] }; # first defined win | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 134 | $node->[3] = undef; # only let these be defined once - at the front of the tree | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ### allow for bare variable getting and setting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } elsif (defined(my $var = $self->parse_expr($str_ref))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 4700 | ▶ | if ($post_op && $self->{'SEMICOLONS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$post_op and $self->{"SEMICOLONS"}
MC/DC100%2/2
$post_op and $self->{"SEMICOLONS"}
$post_op
$self->{"SEMICOLONS"}
Truth table100%3/3
A and B
A= $post_opB= $self->{"SEMICOLONS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 15 | $self->throw('parse', "Missing semi-colon with SEMICOLONS => 1", undef, $node->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4685 | push @$pointer, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4685 | ▶ | if ($$str_ref =~ m{ \G \s* $QR_COMMENTS ($QR_OP_ASSIGN) >? (?! [+=~-]? $self->{'_end_tag'}) \s* $QR_COMMENTS }gcx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 750 | $node->[0] = 'SET'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 750 | $node->[3] = eval { $dirs->{'SET'}->[0]->($self, $str_ref, $node, $1, $var) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 750 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $err->node($node) if UNIVERSAL::can($err, 'node') && ! $err->node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
UNIVERSAL::can($err, "node") and not $err->node
MC/DC0%0/2
UNIVERSAL::can($err, "node") and not $err->node
UNIVERSAL::can($err, "node")
not $err->node
Truth table0%0/3
A and not(B)
A= UNIVERSAL::can($err, "node")B= not $err->node
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3935 | ▶ | if ($self->{'AUTO_FILTER'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 21 | ▶ | $var = [[undef, '~', $var], 0] if ! ref $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 21 | ▶ | push @$var, '|', $self->{'AUTO_FILTER'}, 0 if @$var < 3 || $var->[-3] ne '|'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$var < 3 or $var->[-3] ne "|"
MC/DC100%2/2
@$var < 3 or $var->[-3] ne "|"
@$var < 3
$var->[-3] ne "|"
Truth table100%3/3
A or B
A= @$var < 3B= $var->[-3] ne "|"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3935 | $node->[0] = 'GET'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3935 | $node->[3] = $var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 4685 | $node->[2] = pos $$str_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ### look for the closing tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 8714 | ▶ | if ($$str_ref =~ m{ \G \s* $QR_COMMENTS (?: ; \s* $QR_COMMENTS)? ([+=~-]?) $self->{'_end_tag'} }gcxs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 6965 | ▶ | if ($one_tag_only) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 27 | ▶ | $self->throw('parse', "Invalid char \"$1\" found at end of block") if $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 27 | ▶ | $self->throw('parse', "Missing END directive", $state[-1], pos($$str_ref)) if @state > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 27 | return \@tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 6938 | ▶ | $post_chomp = $1 || $self->{'POST_CHOMP'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$1 || $self->{'POST_CHOMP'}
MC/DC100%2/2
$1 || $self->{'POST_CHOMP'}
$1
$self->{'POST_CHOMP'}
Truth table100%3/3
A || B
A= $1B= $self->{'POST_CHOMP'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 6938 | ▶ | $post_chomp =~ y/-=~+/1230/ if $post_chomp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 6938 | $continue = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 6938 | $post_op = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 6938 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ### semi-colon = end of statement - we will need to continue parsing this tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1749 | ▶ | if ($$str_ref =~ m{ \G ; \s* $QR_COMMENTS }gcxo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1200 | $post_op = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | ### we are flagged to start capturing the output of the next directive - set it up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } elsif ($node->[6]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 136 | $post_op = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 136 | $capture = $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ### allow next directive to be post-operative (or not) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 413 | $post_op = $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | ### no closing tag yet - no need to get an opening tag on next loop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1749 | ▶ | $self->throw('parse', "Not sure how to handle tag", $node, pos($$str_ref)) if $continue == pos $$str_ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1742 | $continue = pos $$str_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | ### cleanup the tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 4097 | ▶ | unshift(@tree, @blocks) if @blocks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 4097 | ▶ | unshift(@tree, ['META', 1, 1, \@meta]) if @meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 4097 | ▶ | $self->throw('parse', "Missing END directive", $state[-1], pos($$str_ref)) if @state > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ### pull off the last text portion - if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 4082 | ▶ | if (pos($$str_ref) != length($$str_ref)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1013 | my $text = substr $$str_ref, pos($$str_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1013 | ▶ | if (! $post_chomp) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 29 | elsif ($post_chomp == 1) { $text =~ s{ ^ [^\S\n]* \n }{}x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | elsif ($post_chomp == 2) { $text =~ s{ ^ \s+ }{ }x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 30 | elsif ($post_chomp == 3) { $text =~ s{ ^ \s+ }{}x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1013 | ▶ | push @$pointer, $text if length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 4082 | return \@tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 3623 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=74 SCAR=46.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 3623 | my ($self, $in, $swap, $out, @ARGS) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 3623 | delete $self->{'error'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 3623 | ▶ | if ($self->{'DEBUG'}) { # "enable" some types of tt style debugging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 24 | ▶ | $self->{'_debug_dirs'} = 1 if $self->{'DEBUG'} =~ /^\d+$/ ? $self->{'DEBUG'} & 8 : $self->{'DEBUG'} =~ /dirs|all/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 24 | ▶ | $self->{'_debug_undef'} = 1 if $self->{'DEBUG'} =~ /^\d+$/ ? $self->{'DEBUG'} & 2 : $self->{'DEBUG'} =~ /undef|all/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 3623 | my $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 3623 | ▶ | $args = ($#ARGS == 0 && UNIVERSAL::isa($ARGS[0], 'HASH')) ? {%{$ARGS[0]}} : {@ARGS} if scalar @ARGS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$#ARGS == 0 and UNIVERSAL::isa($ARGS[0], "HASH")
MC/DC0%0/2
$#ARGS == 0 and UNIVERSAL::isa($ARGS[0], "HASH")
$#ARGS == 0
UNIVERSAL::isa($ARGS[0], "HASH")
Truth table33%1/3
A and B
A= $#ARGS == 0B= UNIVERSAL::isa($ARGS[0], "HASH")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ### get the content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 3623 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 3623 | ▶ | if (ref $in) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 3622 | ▶ | if (ref($in) eq 'SCALAR') { # reference to a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 3618 | $content = $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } elsif (UNIVERSAL::isa($in, 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | $in = $in->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | $content = \$in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } elsif (ref($in) eq 'HASH') { # pre-prepared document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | $content = $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } else { # should be a file handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | $in = <$in>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 2 | $content = \$in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ### should be a filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | $content = $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ### prepare block localization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 3623 | ▶ | my $blocks = $self->{'BLOCKS'} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"BLOCKS"} ||= {}
MC/DC100%1/1
$self->{"BLOCKS"} ||= {}
$self->{"BLOCKS"}
Truth table100%2/2
A
A= $self->{"BLOCKS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | ### do the swap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 3623 | my $output = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 3623 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ### localize the stash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 3623 | ▶ | $swap ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$swap ||= {}
MC/DC100%1/1
$swap ||= {}
$swap
Truth table100%2/2
A
A= $swap
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 3623 | ▶ | my $var1 = $self->{'_vars'} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_vars"} ||= {}
MC/DC100%1/1
$self->{"_vars"} ||= {}
$self->{"_vars"}
Truth table100%2/2
A
A= $self->{"_vars"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 3623 | ▶ | my $var2 = $self->{'STASH'} || $self->{'VARIABLES'} || $self->{'PRE_DEFINE'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%8/8
$self->{'STASH'} || $self->{'VARIABLES'} || $self->{'PRE_DEFINE'} || {}
$self->{"STASH"} or $self->{"VARIABLES"} or $self->{"PRE_DEFINE"}
$self->{"STASH"} or $self->{"VARIABLES"}
MC/DC100%3/3
$self->{'STASH'} || $self->{'VARIABLES'} || $self->{'PRE_DEFINE'} || {}
$self->{"STASH"}
$self->{"VARIABLES"}
$self->{"PRE_DEFINE"}
Truth table100%4/4
A or B or C
A= $self->{"STASH"}B= $self->{"VARIABLES"}C= $self->{"PRE_DEFINE"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 3623 | ▶ | $var1->{'global'} ||= {}; # allow for the "global" namespace - that continues in between processing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$var1->{"global"} ||= {}
MC/DC100%1/1
$var1->{"global"} ||= {}
$var1->{"global"}
Truth table100%2/2
A
A= $var1->{"global"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 3623 | my $copy = {%$var2, %$var1, %$swap}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3623 | local $self->{'BLOCKS'} = $blocks = {%$blocks}; # localize blocks - but save a copy to possibly restore | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 3623 | local $self->{'_template'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 3623 | delete $self->{'_debug_off'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 3623 | delete $self->{'_debug_format'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ### handle pre process items that go before every document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 3623 | my $pre = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 3623 | ▶ | if ($self->{'PRE_PROCESS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 36 | _load_template_meta($self, $content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 36 | foreach my $name (@{ $self->split_paths($self->{'PRE_PROCESS'}) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 39 | $self->_process($name, $copy, \$pre); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | ### process the central file now - catching errors to allow for the ERROR config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 3620 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 3620 | ▶ | local $self->{'STREAM'} = undef if $self->{'WRAPPER'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ### handle the PROCESS config - which loads another template in place of the real one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 3620 | ▶ | if (exists $self->{'PROCESS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 33 | _load_template_meta($self, $content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 33 | foreach my $name (@{ $self->split_paths($self->{'PROCESS'}) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 39 | ▶ | next if ! length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 39 | $self->_process($name, $copy, \$output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | ### handle "normal" content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 3587 | local $self->{'_start_top_level'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 3587 | $self->_process($content, $copy, \$output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ### catch errors with ERROR config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 3620 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 201 | ▶ | $err = $self->exception('undef', $err) if ! UNIVERSAL::can($err, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 201 | ▶ | die $err if $err->type =~ /stop|return/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 201 | ▶ | my $catch = $self->{'ERRORS'} || $self->{'ERROR'} || die $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$self->{'ERRORS'} || $self->{'ERROR'} || die($err)
$self->{"ERRORS"} or $self->{"ERROR"}
MC/DC100%2/2
$self->{'ERRORS'} || $self->{'ERROR'} || die($err)
$self->{"ERRORS"}
$self->{"ERROR"}
Truth table100%3/3
A or B
A= $self->{"ERRORS"}B= $self->{"ERROR"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 45 | ▶ | $catch = {default => $catch} if ! ref $catch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 45 | my $type = $err->type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 45 | my $last_found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | my $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 45 | foreach my $name (keys %$catch) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 60 | ▶ | my $_name = (! defined $name || lc($name) eq 'default') ? '' : $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $name or lc $name eq "default"
MC/DC50%1/2
not defined $name or lc $name eq "default"
not defined $name
lc $name eq "default"
Truth table66%2/3
not(A) or B
A= not defined $nameB= lc $name eq "default"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 60 | ▶ | if ($type =~ / ^ \Q$_name\E \b /x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$type =~ / ^ \Q$_name\E \b /x and !defined($last_found) || length $last_found < length $_name
not defined $last_found or length $last_found < length $_name
MC/DC100%3/3
$type =~ / ^ \Q$_name\E \b /x and !defined($last_found) || length $last_found < length $_name
$type =~ / ^ \Q$_name\E \b /x
not defined $last_found
length $last_found < length $_name
Truth table100%4/4
A and not(B) or C
A= $type =~ / ^ \Q$_name\E \b /xB= not defined $last_foundC= length $last_found < length $_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | && (! defined($last_found) || length($last_found) < length($_name))) { # more specific wins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 49 | $last_found = $_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 49 | $file = $catch->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ### found error handler - try it out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 45 | ▶ | if (defined $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 45 | $output = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 45 | ▶ | local $copy->{'error'} = local $copy->{'e'} = $self->{'COMPILE_JS'} ? {type => $type, info => $err->info} : $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 45 | ▶ | local $self->{'STREAM'} = undef if $self->{'WRAPPER'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 45 | $self->_process($file, $copy, \$output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ### handle wrapper directives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 3464 | ▶ | if (exists $self->{'WRAPPER'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 39 | _load_template_meta($self, $content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 39 | foreach my $name (reverse @{ $self->split_paths($self->{'WRAPPER'}) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 42 | ▶ | next if ! length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 42 | local $copy->{'content'} = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 42 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 42 | local $self->{'STREAM'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 42 | $self->_process($name, $copy, \$out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 39 | $output = $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 36 | ▶ | if ($self->{'STREAM'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 12 | print $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 12 | $output = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 3461 | ▶ | $output = $pre . $output if length $pre; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ### handle post process items that go after every document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 3461 | ▶ | if ($self->{'POST_PROCESS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 36 | _load_template_meta($self, $content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 36 | foreach my $name (@{ $self->split_paths($self->{'POST_PROCESS'}) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 39 | $self->_process($name, $copy, \$output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ### clear blocks as asked (AUTO_RESET) defaults to on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3623 | ▶ | $self->{'BLOCKS'} = $blocks if exists($self->{'AUTO_RESET'}) && ! $self->{'AUTO_RESET'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"AUTO_RESET"} and not $self->{"AUTO_RESET"}
MC/DC0%0/2
exists $self->{"AUTO_RESET"} and not $self->{"AUTO_RESET"}
exists $self->{"AUTO_RESET"}
not $self->{"AUTO_RESET"}
Truth table33%1/3
A and not(B)
A= exists $self->{"AUTO_RESET"}B= not $self->{"AUTO_RESET"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 3623 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 165 | ▶ | $err = $self->exception('undef', $err) if ! UNIVERSAL::can($err, 'type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 165 | ▶ | if ($err->type !~ /stop|return|next|last|break/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 165 | $self->{'error'} = $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 165 | ▶ | die $err if $self->{'RAISE_ERROR'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 165 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ### send the content back out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 3458 | ▶ | $out ||= $self->{'OUTPUT'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$out ||= $self->{"OUTPUT"}
MC/DC100%2/2
$out ||= $self->{"OUTPUT"}
$out
$self->{"OUTPUT"}
Truth table100%3/3
A ||= B
A= $outB= $self->{"OUTPUT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 3458 | ▶ | if (ref $out) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 3455 | ▶ | if (UNIVERSAL::isa($out, 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | $out->($output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } elsif (UNIVERSAL::can($out, 'print')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | $out->print($output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } elsif (UNIVERSAL::isa($out, 'SCALAR')) { # reference to a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 3450 | $$out = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } elsif (UNIVERSAL::isa($out, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1 | push @$out, $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } else { # should be a file handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | print {$out} $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } elsif ($out) { # should be a filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 2 | my $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | ▶ | if ($out =~ m|^/|) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if (! $self->{'ABSOLUTE'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $self->throw($self->{'error'} = $self->exception('file', "ABSOLUTE paths disabled")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $file = $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } elsif ($out =~ m|^\.\.?/|) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if (! $self->{'RELATIVE'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $self->throw($self->{'error'} = $self->exception('file', "RELATIVE paths disabled")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $file = $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | my $path = $self->{'OUTPUT_PATH'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 2 | ▶ | $path = '.' if ! defined $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2 | ▶ | if (! -d $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | require File::Path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | File::Path::mkpath($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | $file = "$path/$out"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | open(my $fh, '>', $file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 2 | ▶ | || $self->throw($self->{'error'} = $self->exception('file', "$out couldn't be opened for writing: $!")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 2 | ▶ | if (my $bm = $args->{'binmode'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 1 | ▶ | if (+$bm == 1) { binmode $fh } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | else { binmode $fh, $bm } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } elsif ($self->{'ENCODING'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | if (eval { require Encode } && defined &Encode::encode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
eval {
do {
require Encode
}
} and defined &Encode::encode
MC/DC0%0/2
eval {
do {
require Encode
}
} and defined &Encode::encode
eval {
do {
require Encode
}
}
defined &Encode::encode
Truth table0%0/3
A and B
A= eval {
do {
require Encode
}
}B= defined &Encode::encode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $output = Encode::encode($self->{'ENCODING'}, $output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 2 | print {$fh} $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | print $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 3458 | ▶ | return if $self->{'error'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 3452 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 144 | ▶ | sub _load_template_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_template_meta: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 144 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 144 | ▶ | return if $self->{'_template'}; # only do once as need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 129 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | ### load the meta data for the top document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | ### this is needed by some of the custom handlers such as PRE_PROCESS and POST_PROCESS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 129 | my $content = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 129 | ▶ | my $doc = $self->{'_template'} = ref($content) eq 'HASH' ? $content : $self->load_template($content) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->load_template($content) or {}
MC/DC0%0/1
$self->load_template($content) or {}
$self->load_template($content)
Truth table50%1/2
A
A= $self->load_template($content)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | my $meta = $doc->{'_perl'} ? $doc->{'_perl'}->{'meta'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 129 | ▶ | : ($doc->{'_tree'} && ref($doc->{'_tree'}->[0]) && $doc->{'_tree'}->[0]->[0] eq 'META') ? $doc->{'_tree'}->[0]->[3] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
$doc->{"_tree"} and ref $doc->{"_tree"}[0] and $doc->{"_tree"}[0][0] eq "META"
$doc->{"_tree"} and ref $doc->{"_tree"}[0]
MC/DC66%2/3
$doc->{"_tree"} and ref $doc->{"_tree"}[0] and $doc->{"_tree"}[0][0] eq "META"
$doc->{"_tree"}
ref $doc->{"_tree"}[0]
$doc->{"_tree"}[0][0] eq "META"
Truth table75%3/4
A and B and C
A= $doc->{"_tree"}B= ref $doc->{"_tree"}[0]C= $doc->{"_tree"}[0][0] eq "META"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 129 | ▶ | $meta = {@$meta} if ref($meta) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 129 | $self->{'_template'} = $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 129 | @{ $doc }{keys %$meta} = values %$meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 129 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||