MojoX/Renderer/Alloy/HTE.pm

filter: Statementstmt 42.5% 20 / 47 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 75.0% 6 / 8 Podpod n/a totaltotal 32.1% 26 / 81 CC 10 SCAR 38.9
CC
10
Cov
29%
_render
90.0
_init
6.0
BEGIN
1.0
CRAP 48.7
« MojoX/Renderer/Alloy/Tmpl.pm ↑ Summary MojoX/Renderer/Alloy.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package MojoX::Renderer::Alloy::HTE;
4 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 $MojoX::Renderer::Alloy::HTE::AUTHORITY = 'cpan:AJGB';
6 }
7 {
8 3 $MojoX::Renderer::Alloy::HTE::VERSION = '1.121150';
9 }
10 #ABSTRACT: Template::Alloy's HTML::Template::Expr renderer
11  
12 3 ▶use base 'MojoX::Renderer::Alloy';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use Template::Alloy qw( HTE );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 __PACKAGE__->attr('_hte_config');
18  
19  
20 0 ▶sub _init {
Subroutine _init: not called CC=2 SCAR=17.9
21 0 my $self = shift;
22  
23 0 my %config = $self->_default_config(@_);
24  
25 $config{path} = $config{INCLUDE_PATH}
26 0 ▶ unless exists $config{path};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $config{"path"} 0 0 0
27  
28 0 $self->_hte_config( \%config );
29 }
30  
31 0 ▶sub _render {
Subroutine _render: not called CC=9 SCAR=45.0
32 0 my ($self, $r, $c, $output, $options) = @_;
33  
34 0 my $inline = $options->{inline};
35  
36 0 my $tname = $r->template_name($options);
37 0 my $path = $r->template_path($options);
38  
39 0 ▶ return unless defined $inline || ( defined $path && defined $tname );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $inline or defined $path and defined $tname 0 0 0
Condition0%0/6
defined $inline or defined $path and defined $tname
l!l&&r!l&&!r
000
defined $path and defined $tname
!ll&&!rl&&r
000
MC/DC0%0/3
defined $inline or defined $path and defined $tname
defined $inline defined $path defined $tname
Truth table0%0/4
A or B and C
A= defined $inlineB= defined $pathC= defined $tname
ABCresult
1XX1
0111
00X0
0100
40  
41  
42 0 my $alloy;
43 # inline
44 0 ▶ if ( defined $inline ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $inline) { } 0 0 0
elsif (-r $path) { } 0 0 0
45 $alloy = Template::Alloy->new(
46 type => 'scalarref',
47 source => \$inline,
48 0 %{ $self->_hte_config },
49 );
50 }
51 # regular file
52 elsif ( -r $path ) {
53 $alloy = Template::Alloy->new(
54 type => 'filename',
55 source => $path,
56 0 %{ $self->_hte_config },
57 );
58 }
59 else {
60 # inlined templates are not supported
61 0 ▶ if ( $r->get_data_template($options, $tname) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r->get_data_template($options, $tname)) { } 0 0 0
62 0 $c->render_exception(
63 "Inlined templates are not supported"
64 );
65 } else {
66 0 $c->render_not_found( $tname );
67 };
68 0 return;
69 }
70  
71 0 $alloy->param(
72 $self->_template_vars( $c )
73 );
74  
75 0 eval {
76 0 $$output = $alloy->output();
77 };
78 0 ▶ if ( my $e = $alloy->error || $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $alloy->error || $@) 0 0 0
Condition0%0/3
$alloy->error || $@
l!l&&r!l&&!r
000
MC/DC0%0/2
$alloy->error || $@
$alloy->error $@
Truth table0%0/3
A || B
A= $alloy->errorB= $@
ABresult
1X1
011
000
79 0 chomp $e;
80 0 $c->render_exception( $e );
81  
82 0 return;
83 };
84  
85 0 return 1;
86 }
87  
88 3 1;
89  
90 __END__
« MojoX/Renderer/Alloy/Tmpl.pm ↑ Summary MojoX/Renderer/Alloy.pm »