Templated/View/TT.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 84.7% 39 / 46 CC 5 SCAR 11.5
CC
5
Cov
85%
process
5.8
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« Templated.pm ↑ Summary Templated/Util.pm »
1 package MooseX::Templated::View::TT;
2  
3 =head1 NAME
4  
5 MooseX::Templated::View::TT - Template Toolkit View for MooseX::Templated
6  
7 =head1 SYNOPSIS
8  
9 See L<MooseX::Templated::View>
10  
11 =cut
12  
13 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 4 with 'MooseX::Templated::View';
19  
20 4 my %TT_DEFAULT_CONFIG = (
21 'ABSOLUTE' => 1, # required for using default module name
22 );
23  
24 =head2 build_default_template_suffix
25  
26 =cut
27  
28 3 ▶sub build_default_template_suffix { '.tt' }
Subroutine build_default_template_suffix: called CC=1 SCAR=0.0
Pod documented
29  
30 =head2 build_renderer
31  
32 =cut
33  
34 3 ▶sub build_renderer {
Subroutine build_renderer: called CC=1 SCAR=0.0
Pod documented
35 3 my $self = shift;
36 3 return Template->new( %TT_DEFAULT_CONFIG );
37 }
38  
39 =head2 process( $source, $model )
40  
41 Processes the model using the TT source and returns the output as a string
42  
43 =cut
44  
45 13 ▶sub process {
Subroutine process: called CC=5 SCAR=17.5
Pod documented
46 13 my ($self, $source, $model) = @_;
47  
48 13 ▶ croak "! Error: expected 'source'" unless $source;
Branch: 1 branch
BranchTrueFalseTotal
unless $source 0 13 13
49 13 ▶ croak "! Error: expected 'model' to be Moose object"
Branch: 1 branch
BranchTrueFalseTotal
unless $model and builtin::blessed($model) 0 13 13
Condition33%1/3
$model and builtin::blessed($model)
!ll&&!rl&&r
0013
MC/DC0%0/2
$model and builtin::blessed($model)
$model builtin::blessed($model)
Truth table33%1/3
A and B
A= $modelB= builtin::blessed($model)
ABresult
0X0
100
111
50 if ( ! $model || ! blessed $model );
51  
52 13 my $tt_output = '';
53  
54 13 my %stash = ( self => $model );
55  
56 13 ▶ $self->renderer->process( \$source, \%stash, \$tt_output )
Branch: 1 branch
BranchTrueFalseTotal
$self->renderer->process(\$source, \%stash, \$tt_output) or croak(q[couldn't process template (module: ] . $self->view_class . ")\n" . "\t" . $self->renderer->error) 13 0 13
57 or croak( "couldn't process template (module: ".($self->view_class).")\n".
58 "\t".$self->renderer->error() );
59  
60 13 return $tt_output;
61 }
62  
63 4 1; # Magic true value required at end of module
64 __END__
« Templated.pm ↑ Summary Templated/Util.pm »