FormHandler/Render/WithTT.pm

filter: Statementstmt 89.1% 41 / 46 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 76.9% 10 / 13 Podpod 0.0% 0 / 8 totaltotal 75.3% 52 / 69 CC 2 SCAR 3.1
CC
2
Cov
88%
tt_render
2.1
build_tt_include_path
2.0
build_tt_template
2.0
CRAP 1.4
« FormHandler/Field/Repeatable/Instance.pm ↑ Summary FormHandler/Field/TextArea.pm »
1 package HTML::FormHandler::Render::WithTT;
2 # ABSTRACT: tt rendering
3 4 $HTML::FormHandler::Render::WithTT::VERSION = '0.410002';
4 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use File::ShareDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use HTML::FormHandler::Render::Util ('process_attrs');
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 4 has 'tt_include_path' => (
12 traits => ['Array'],
13 is => 'rw',
14 isa => 'ArrayRef',
15 lazy => 1,
16 builder => 'build_tt_include_path',
17 handles => {
18 add_tt_include_path => 'push',
19 }
20 );
21 0 ▶sub build_tt_include_path {[]}
Subroutine build_tt_include_path: not called CC=1 SCAR=6.9
Pod undocumented
22  
23 4 has 'tt_config' => (
24 traits => ['Hash'],
25 is => 'rw',
26 lazy => 1,
27 builder => 'build_tt_config',
28 );
29 5 ▶sub build_tt_config {
Subroutine build_tt_config: called CC=1 SCAR=0.0
Pod undocumented
30 5 my $self = shift;
31 return {
32 INCLUDE_PATH => [
33 5 @{ $self->tt_include_path },
34 File::ShareDir::dist_dir('HTML-FormHandler') . '/templates/'
35 ]
36 };
37 }
38  
39 # either file name string or string ref?
40 4 has 'tt_template' => ( is => 'rw', isa => 'Str', lazy => 1,
41 builder => 'build_tt_template' );
42 0 ▶sub build_tt_template { 'form/form.tt' }
Subroutine build_tt_template: not called CC=1 SCAR=6.9
Pod undocumented
43  
44 4 has 'tt_engine' => ( is => 'rw', isa => 'Template', lazy => 1,
45 builder => 'build_tt_engine'
46 );
47 5 ▶sub build_tt_engine {
Subroutine build_tt_engine: called CC=1 SCAR=0.0
Pod undocumented
48 5 my $self = shift;
49  
50 5 my $tt_engine = Template->new( $self->tt_config );
51 5 return $tt_engine;
52 }
53  
54 4 has 'tt_vars' => ( is => 'rw', traits => ['Hash'],
55 builder => 'build_tt_vars');
56 5 ▶sub build_tt_vars {{}}
Subroutine build_tt_vars: called CC=1 SCAR=0.0
Pod undocumented
57  
58 4 has 'default_tt_vars' => ( is => 'ro', isa => 'HashRef',
59 lazy => 1, builder => 'build_default_tt_vars' );
60 5 ▶sub build_default_tt_vars {
Subroutine build_default_tt_vars: called CC=1 SCAR=0.0
Pod undocumented
61 5 my $self = shift;
62 5 return { form => $self->form, process_attrs => \&process_attrs };
63 }
64  
65 4 has 'tt_default_options' => (
66 traits => ['Hash'],
67 is => 'rw',
68 isa => 'HashRef',
69 lazy => 1,
70 builder => 'build_tt_default_options',
71 );
72 0 ▶sub build_tt_default_options {{}}
Subroutine build_tt_default_options: not called CC=1 SCAR=6.9
Pod undocumented
73  
74  
75 5 ▶sub tt_render {
Subroutine tt_render: called CC=2 SCAR=7.2
Pod undocumented
76 5 my $self = shift;
77  
78 5 my $output;
79 5 my $vars = { %{$self->default_tt_vars}, %{$self->tt_vars} };
80 5 $self->tt_engine->process( $self->tt_template, $vars, \$output );
81  
82 5 ▶ if( my $exception = $self->tt_engine->{SERVICE}->{_ERROR} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $exception = $self->tt_engine->{"SERVICE"}{"_ERROR"}) 0 5 5
83  
84 0 die $exception->[0] . " " . $exception->[1] . ". So far => " . ${$exception->[2]} . "\n";
85 }
86 5 return $output;
87 }
88  
89 4 1;
90  
91 __END__
« FormHandler/Field/Repeatable/Instance.pm ↑ Summary FormHandler/Field/TextArea.pm »