| 1 | package Kelp::Module::Template; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 37 | ▶ | use Kelp::Base 'Kelp::Module'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 37 | ▶ | use Kelp::Template; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 37 | attr ext => 'tt'; | |||||||||||||||||||
| 7 | 0 | ▶ | attr engine => sub { die "'engine' must be initialized" }; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | sub build | ||||||||||||||||||||
| 10 | 50 | ▶ | { | ||||||||||||||||||
|
Subroutine
build: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 11 | 50 | my ($self, %args) = @_; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | # Build and initialize the engine attribute | ||||||||||||||||||||
| 14 | 50 | $self->engine($self->build_engine(%args)); | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # Register one method - template | ||||||||||||||||||||
| 17 | $self->register( | ||||||||||||||||||||
| 18 | 82 | ▶ | template => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||
| 19 | 82 | my ($app, $template, $vars, @rest) = @_; | |||||||||||||||||||
| 20 | 82 | ▶ | $vars //= {}; | ||||||||||||||||||
|
Condition100%2/2
$vars //= {}
MC/DC100%1/1
$vars //= {}
$vars
Truth table100%2/2
A
A= $vars
| |||||||||||||||||||||
| 21 | 82 | ▶ | $vars->{app} //= $app; | ||||||||||||||||||
|
Condition33%1/3
$vars->{"app"} //= $app
MC/DC0%0/2
$vars->{"app"} //= $app
$vars->{"app"}
$app
Truth table33%1/3
A //= B
A= $vars->{"app"}B= $app
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 82 | return $self->render($self->_rename($template), $vars, @rest); | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | 50 | ); | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | sub build_engine | ||||||||||||||||||||
| 29 | 48 | ▶ | { | ||||||||||||||||||
|
Subroutine
build_engine: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 30 | 48 | my ($self, %args) = @_; | |||||||||||||||||||
| 31 | 48 | return Kelp::Template->new(%args); | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | sub render | ||||||||||||||||||||
| 35 | 78 | ▶ | { | ||||||||||||||||||
|
Subroutine
render: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 36 | 78 | my ($self, $template, $vars) = @_; | |||||||||||||||||||
| 37 | 78 | return $self->engine->process($template, $vars); | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | sub _rename | ||||||||||||||||||||
| 41 | 85 | ▶ | { | ||||||||||||||||||
|
Subroutine
_rename: called CC=7 SCAR=19.5
| |||||||||||||||||||||
| 42 | 85 | my ($self, $name) = @_; | |||||||||||||||||||
| 43 | 85 | ▶ | $name //= ''; | ||||||||||||||||||
|
Condition100%2/2
$name //= ""
MC/DC100%1/1
$name //= ""
$name
Truth table100%2/2
A
A= $name
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 85 | ▶ | return $name if ref $name; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | 80 | ▶ | return undef unless length $name; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 78 | ▶ | my $ext = $self->ext // ''; | ||||||||||||||||||
|
Condition100%2/2
$self->ext // ""
MC/DC100%1/1
$self->ext // ""
$self->ext
Truth table100%2/2
A
A= $self->ext
| |||||||||||||||||||||
| 49 | 78 | ▶ | return $name unless length $ext; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 76 | ▶ | return $name if $name =~ /\./; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 75 | return "$name.$ext"; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 37 | 1; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||