AutoCRUD/View/TT.pm

filter: Statementstmt 100% 41 / 41 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 3 totaltotal 88.8% 56 / 63 CC 4 SCAR 4.4
CC
4
Cov
94%
render
3.0
default_dashed_args
2.1
BEGIN
1.0
CRAP 1.5
« AutoCRUD/View/Yaml.pm ↑ Summary AutoCRUD/Controller.pm »
1 package App::AutoCRUD::View::TT;
2
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 extends 'App::AutoCRUD::View';
9
10 1 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Template::Filters ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Encode qw/encode_utf8/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13
14 1 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
15
16 7 ▶has 'tt_args' => ( is => 'bare', isa => 'HashRef', default => sub {{}} );
Subroutine __ANON__: called CC=1 SCAR=0.0
17
18
19 7 ▶sub render {
Subroutine render: called CC=3 SCAR=11.1
Pod undocumented
20 7 my ($self, $data, $context) = @_;
21
22 # where to find templates
23 7 my @dirs = map {"$_/templates"} $context->app->share_paths;
24 7 unshift @dirs, $context->dir . "/templates";
25
26 my %tt_args = (
27 INCLUDE_PATH => \@dirs,
28 PRE_PROCESS => 'lib/config',
29 WRAPPER => 'lib/site/wrapper',
30 ERROR => 'src/error.tt',
31 ENCODING => 'utf8',
32 FILTERS => { utf8_url => \&utf8_url },
33 7 %{$self->{tt_args}},
34 );
35
36 7 my $renderer = Template->new(%tt_args);
37 7 ▶ my $template = $context->template
Branch: 1 branch
BranchTrueFalseTotal
my $template = $context->template or die "no template for TT view" 7 0 7
38 or die "no template for TT view";
39 7 ▶ $renderer->process("src/$template",
Branch: 1 branch
BranchTrueFalseTotal
$renderer->process("src/$template", {"data", $data, "c", $context}, \my $output) or die $renderer->error 7 0 7
40 {data => $data, c => $context},
41 \my $output)
42 or die $renderer->error;
43
44 7 return [200, ['Content-type' => 'text/html; charset=utf-8',
45 'X-UA-Compatible' => "IE=edge", # enforce latest MSIE rendering
46 ],
47 [encode_utf8($output)] ];
48 }
49
50
51 2 ▶sub default_dashed_args {
Subroutine default_dashed_args: called CC=2 SCAR=7.2
Pod undocumented
52 2 my ($self, $context) = @_;
53
54 2 ▶ return (-page_index => 1,
Condition50%1/2
$context->app->default('page_size') || 50
l!l
02
MC/DC0%0/1
$context->app->default('page_size') || 50
$context->app->default('page_size')
Truth table50%1/2
A
A= $context->app->default('page_size')
Aresult
11
00
55 -page_size => ($context->app->default('page_size') || 50));
56 }
57
58
59 45 ▶sub utf8_url {
Subroutine utf8_url: called CC=1 SCAR=0.0
Pod undocumented
60 45 my $data = shift;
61 45 return Template::Filters::url_filter(encode_utf8($data));
62 }
63
64
65
66
67 1 1;
68
69
70 __END__
« AutoCRUD/View/Yaml.pm ↑ Summary AutoCRUD/Controller.pm »