lib/Template/Mustache/Token/Section.pm

filter: Statementstmt 90.3% 28 / 31 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 79.5% 39 / 49 CC 7 SCAR 18.1
CC
7
Cov
79%
render
9.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.1
« lib/Template/Mustache/Parser.pm ↑ Summary lib/Template/Mustache/Token/Template.pm »
1 package Template::Mustache::Token::Section;
2 22 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: Object representing a Section block
4 22 $Template::Mustache::Token::Section::VERSION = '1.4.0';
5 22 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 22 ▶use MooseX::MungeHas { has_ro => [ 'is_ro' ] };
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 22 has_ro 'variable';
10 22 has_ro 'template';
11 22 has_ro 'inverse';
12 22 has_ro 'delimiters';
13 22 has_ro 'raw';
14  
15 22 ▶use Template::Mustache;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 11 ▶sub render {
Subroutine render: called CC=7 SCAR=22.0
Pod undocumented
18 11 my( $self, $context, $partials, $indent ) = @_;
19  
20 11 my $cond = Template::Mustache::resolve_context( $self->variable, $context );
21  
22 11 ▶ if ( ref $cond eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cond eq "CODE") 2 9 11
23 my $value=Template::Mustache->new(
24 delimiters => $self->delimiters,
25 template => $cond->(
26 $self->raw,
27 2 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 2 Template::Mustache->new( template=> shift )->parsed->render(
29 $context, $partials, $indent
30 ) }
31 )
32 2 )->parsed->render( $context, $partials );
33  
34 2 ▶ return '' if $self->inverse;
Branch: 1 branch
BranchTrueFalseTotal
if $self->inverse 0 2 2
35 2 return $value;
36 }
37  
38 9 ▶ if ( $self->inverse ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->inverse) 0 9 9
39 0 ▶ if ( ref $cond eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cond eq 'ARRAY') { } 0 0 0
40 0 $cond = ! @$cond;
41 }else {
42 0 $cond = !$cond;
43 }
44 }
45  
46 9 ▶ return unless $cond;
Branch: 1 branch
BranchTrueFalseTotal
unless $cond 0 9 9
47  
48 9 ▶ return join '', map { $self->template->render( [ $_, @$context ], $partials ) }
Branch: 1 branch
BranchTrueFalseTotal
ref $cond eq 'ARRAY' ? : 0 9 9
49 ref $cond eq 'ARRAY' ? @$cond : ( $cond );
50 }
51  
52 22 1;
53  
54 __END__
« lib/Template/Mustache/Parser.pm ↑ Summary lib/Template/Mustache/Token/Template.pm »