| 1 | package Dancer::Template::Mason2; | ||||||||||||||||||||||||
| 2 | 2 | $Dancer::Template::Mason2::VERSION = '0.05'; | |||||||||||||||||||||||
| 3 | 2 | ▶ | use Dancer::Config 'setting'; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 4 | 2 | ▶ | use File::Basename; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 5 | 2 | ▶ | use FindBin; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 6 | 2 | ▶ | use Mason; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 9 | 2 | ▶ | use base 'Dancer::Template::Abstract'; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||
| 11 | 2 | my $_engine; | |||||||||||||||||||||||
| 12 | my $root_dir; | ||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||
| 14 | 1 | ▶ | sub init { | ||||||||||||||||||||||
|
Subroutine
init: called CC=6 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||
| 15 | 1 | my $self = shift; | |||||||||||||||||||||||
| 16 | 1 | ▶ | my $config = $self->config || {}; | ||||||||||||||||||||||
|
Condition50%1/2
$self->config || {}
MC/DC0%0/1
$self->config || {}
$self->config
Truth table50%1/2
A
A= $self->config
| |||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||
| 18 | 1 | ▶ | $root_dir = $config->{comp_root} ||= setting('views') || $FindBin::Bin . '/views'; | ||||||||||||||||||||||
|
Condition40%2/5
$config->{"comp_root"} ||= setting("views") || $FindBin::Bin . '/views'
setting('views') || $FindBin::Bin . '/views'
MC/DC0%0/2
$config->{"comp_root"} ||= setting("views") || $FindBin::Bin . '/views'
$config->{"comp_root"}
setting('views')
Truth table0%0/3
A ||= B
A= $config->{"comp_root"}B= setting('views')
| |||||||||||||||||||||||||
| 19 | 1 | ▶ | $config->{data_dir} ||= dirname($root_dir) . "/data"; | ||||||||||||||||||||||
|
Condition50%1/2
$config->{"data_dir"} ||= dirname($root_dir) . '/data'
MC/DC0%0/1
$config->{"data_dir"} ||= dirname($root_dir) . '/data'
$config->{"data_dir"}
Truth table50%1/2
A
A= $config->{"data_dir"}
| |||||||||||||||||||||||||
| 20 | 1 | ▶ | $config->{autoextend_request_path} = 0 if !exists( $config->{autoextend_request_path} ); | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||
| 22 | 1 | $_engine = Mason->new(%$config); | |||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||
| 25 | 0 | ▶ | sub default_tmpl_ext { "mc" } | ||||||||||||||||||||||
|
Subroutine
default_tmpl_ext: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||
| 27 | 1 | ▶ | sub render { | ||||||||||||||||||||||
|
Subroutine
render: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||
| 28 | 1 | my ( $self, $template, $tokens ) = @_; | |||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||
| 30 | 1 | $template =~ s/^\Q$root_dir//; # cut the leading path | |||||||||||||||||||||||
| 31 | 1 | $template =~ y|\\|/|; # convert slashes on Windows | |||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||
| 33 | 1 | my $content = $_engine->run( $template, %$tokens )->output; | |||||||||||||||||||||||
| 34 | 1 | return $content; | |||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||
| 37 | 0 | ▶ | sub view { | ||||||||||||||||||||||
|
Subroutine
view: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||
| 38 | 0 | my ( $self, $view ) = @_; | |||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||
| 40 | 0 | my $views_dir = Dancer::App->current->setting('views'); | |||||||||||||||||||||||
| 41 | 0 | ▶ | my $tmpl_ext = $self->config->{extension} || $self->default_tmpl_ext(); | ||||||||||||||||||||||
|
Condition0%0/3
$self->config->{'extension'} || $self->default_tmpl_ext
MC/DC0%0/2
$self->config->{'extension'} || $self->default_tmpl_ext
$self->config->{'extension'}
$self->default_tmpl_ext
Truth table0%0/3
A || B
A= $self->config->{'extension'}B= $self->default_tmpl_ext
| |||||||||||||||||||||||||
| 42 | 0 | my $view_path = sprintf( '%s/%s.%s', $views_dir, $view, $self->default_tmpl_ext ); | |||||||||||||||||||||||
| 43 | 0 | return $view_path; | |||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||
| 46 | 0 | ▶ | sub view_exists { return 1; } | ||||||||||||||||||||||
|
Subroutine
view_exists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||
| 48 | 2 | 1; | |||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||||||