lib/Template/Mustache/Token/Variable.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 87.5% 7 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 88.8% 48 / 54 CC 6 SCAR 12.2
CC
6
Cov
93%
render
6.0
__ANON__
2.0
BEGIN
1.0
CRAP 3.4
« lib/Template/Mustache.pm ↑ Summary lib/Template/Mustache/Token/Verbatim.pm »
1 package Template::Mustache::Token::Variable;
2 23 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: Object representing a Variable block
4 23 $Template::Mustache::Token::Variable::VERSION = '1.4.0';
5 23 ▶use Escape::Houdini qw/ escape_html /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 23 ▶use Scalar::Util qw/ looks_like_number /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 23 ▶use Math::BigFloat;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 23 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 23 ▶use MooseX::MungeHas {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 23 has_ro => [ 'is_ro' ] ,
13 has_rw => [ 'is_rw' ] ,
14 23 };
15  
16 23 has_ro 'name';
17  
18 has escape => (
19 is => 'rw',
20 0 ▶ lazy => 1, default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 23 predicate => 1,
22 );
23  
24 67 ▶sub render {
Subroutine render: called CC=6 SCAR=18.0
Pod undocumented
25 67 my( $self, $context,$partials, $indent ) = @_;
26  
27 67 ▶ my $value =
Condition50%1/2
Template::Mustache::resolve_context($self->name, $context) // ""
l!l
670
MC/DC0%0/1
Template::Mustache::resolve_context($self->name, $context) // ""
Template::Mustache::resolve_context($self->name, $context)
Truth table50%1/2
A
A= Template::Mustache::resolve_context($self->name, $context)
Aresult
11
00
28 Template::Mustache::resolve_context( $self->name, $context ) // '';
29  
30 67 ▶ if( ref $value eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "CODE") 2 65 67
31 $value = $value->(
32 2 ▶ sub { Template::Mustache->new( template=> shift )->parsed->render( $context, $partials, $indent ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
33 2 );
34 2 my $template = Template::Mustache->new( template => $value )->parsed;
35 2 $template->escape($self->escape);
36 2 $value = $template->render(
37 $context, $partials, $indent
38 );
39 }
40  
41 67 ▶ return $$value if ref $value eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "SCALAR" 2 65 67
42  
43 65 ▶ eval { $value = escape_html($value) } if $self->escape;
Branch: 1 branch
BranchTrueFalseTotal
if $self->escape 65 0 65
44  
45 65 ▶ $value = Math::BigFloat->new($value)->bstr if looks_like_number($value);
Branch: 1 branch
BranchTrueFalseTotal
if &looks_like_number($value) 5 60 65
46  
47 65 return $value;
48 }
49  
50 23 1;
51  
52 __END__
« lib/Template/Mustache.pm ↑ Summary lib/Template/Mustache/Token/Verbatim.pm »