blib/lib/Dancer/Template/Ctpp2.pm

filter: Statementstmt 57.1% 24 / 42 Branchbran 8.3% 1 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 100% 3 / 3 totaltotal 46.0% 35 / 76 CC 9 SCAR 28.3
CC
9
Cov
42%
render
42.0
init
6.5
default_tmpl_ext
6.0
CRAP 17.0
↑ Summary
1 package Dancer::Template::Ctpp2;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Dancer::Config 'setting';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Dancer::ModuleLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Dancer::FileUtils 'path';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use base 'Dancer::Template::Abstract';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $VERSION = '0.02';
12  
13 2 our $_ctpp2;
14 2 our %_cfg;
15  
16 0 ▶sub default_tmpl_ext {
Subroutine default_tmpl_ext: not called CC=2 SCAR=17.9
Pod documented
17 0 ▶ return ($_cfg{'use_bytecode'}) ? 'ct2' : 'tmpl';
Branch: 1 branch
BranchTrueFalseTotal
$Dancer::Template::Ctpp2::_cfg{'use_bytecode'} ? : 0 0 0
18 }
19  
20  
21 1 ▶sub init {
Subroutine init: called CC=3 SCAR=18.7
Pod documented
22 1 my ($self) = @_;
23  
24 1 ▶ die "HTML::CTPP2 is needed by Dancer::Template::Ctpp2"
Branch: 1 branch
BranchTrueFalseTotal
unless "Dancer::ModuleLoader"->load("HTML::CTPP2") 1 0 1
25 unless Dancer::ModuleLoader->load('HTML::CTPP2');
26
27 0 %_cfg=%{$self->config};
28 0 ▶ my $use_bytecode = (defined $_cfg{'compiled'}) ? delete $_cfg{'compiled'} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $Dancer::Template::Ctpp2::_cfg{'compiled'} ? : 0 0 0
29  
30 0 $_ctpp2 = new HTML::CTPP2(
31 arg_stack_size => 1024,
32 code_stack_size => 1024,
33 steps_limit => 1024*1024,
34 max_functions => 1024,
35 %_cfg,
36 );
37
38 0 $_cfg{'use_bytecode'} = $use_bytecode;
39 }
40  
41 0 ▶sub render($$$) {
Subroutine render: not called CC=6 SCAR=37.4
Pod documented
42 0 my ($self, $template, $tokens) = @_;
43  
44 0 ▶ die "'$template' is not a regular file"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $template or -f $template 0 0 0
Condition0%0/3
ref $template or -f $template
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $template or -f $template
ref $template -f $template
Truth table0%0/3
A or B
A= ref $templateB= -f $template
ABresult
1X1
011
000
45 if !ref($template) && (!-f $template);
46  
47 0 my $b;
48  
49 0 ▶ if ($_cfg{'use_bytecode'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Dancer::Template::Ctpp2::_cfg{'use_bytecode'}) { } 0 0 0
50 0 $b = $_ctpp2->load_bytecode($template);
51 } else {
52 0 $b = $_ctpp2->parse_template($template);
53 }
54  
55 0 $_ctpp2->reset();
56 0 $_ctpp2->param($tokens);
57  
58 0 my $result = $_ctpp2->output($b);
59
60 0 ▶ if(length(setting('charset')) && lc setting('charset') eq 'utf-8') {
Branch: 1 branch
BranchTrueFalseTotal
if (length setting('charset') and lc setting('charset') eq 'utf-8') { } 0 0 0
Condition0%0/3
length setting("charset") and lc setting("charset") eq "utf-8"
!ll&&!rl&&r
000
MC/DC0%0/2
length setting("charset") and lc setting("charset") eq "utf-8"
length setting("charset") lc setting("charset") eq "utf-8"
Truth table0%0/3
A and B
A= length setting("charset")B= lc setting("charset") eq "utf-8"
ABresult
0X0
100
111
61 0 return pack "U0C*", unpack "C*", $result;
62 } else {
63 0 return $result;
64 }
65
66 }
67  
68 2 1;
69 __END__
↑ Summary