| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
ref $template or -f $template
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
| |||||||||||||||||||||||||||||
| 45 | if !ref($template) && (!-f $template); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my $b; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($_cfg{'use_bytecode'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
length setting("charset") and lc setting("charset") eq "utf-8"
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"
| |||||||||||||||||||||||||||||
| 61 | 0 | return pack "U0C*", unpack "C*", $result; | |||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||
| 63 | 0 | return $result; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | 1; | |||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||