| 1 | package Gears::Template::TT; | ||||||||||||||||||||
| 2 | 4 | $Gears::Template::TT::VERSION = '0.107'; | |||||||||||||||||||
| 3 | 4 | ▶ | use v5.40; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 4 | ▶ | use Mooish::Base -standard; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 4 | ▶ | use Template; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 4 | ▶ | use Gears::X::Template; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 4 | extends 'Gears::Template'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | has param 'conf' => ( | ||||||||||||||||||||
| 12 | isa => HashRef, | ||||||||||||||||||||
| 13 | 0 | ▶ | default => sub { {} }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 14 | 4 | ); | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 4 | has field 'engine' => ( | |||||||||||||||||||
| 17 | isa => InstanceOf ['Template'], | ||||||||||||||||||||
| 18 | lazy => 1, | ||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 2 | ▶ | sub _build_engine ($self) | ||||||||||||||||||
|
Subroutine
_build_engine: called CC=3 SCAR=12.7
| |||||||||||||||||||||
| 22 | { | ||||||||||||||||||||
| 23 | 2 | my %conf = $self->conf->%*; | |||||||||||||||||||
| 24 | 2 | ▶ | $conf{ENCODING} //= $self->encoding; | ||||||||||||||||||
|
Condition33%1/3
$conf{"ENCODING"} //= $self->encoding
MC/DC0%0/2
$conf{"ENCODING"} //= $self->encoding
$conf{"ENCODING"}
$self->encoding
Truth table33%1/3
A //= B
A= $conf{"ENCODING"}B= $self->encoding
| |||||||||||||||||||||
| 25 | 2 | ▶ | $conf{INCLUDE_PATH} //= $self->paths; | ||||||||||||||||||
|
Condition33%1/3
$conf{"INCLUDE_PATH"} //= $self->paths
MC/DC0%0/2
$conf{"INCLUDE_PATH"} //= $self->paths
$conf{"INCLUDE_PATH"}
$self->paths
Truth table33%1/3
A //= B
A= $conf{"INCLUDE_PATH"}B= $self->paths
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 2 | return Template->new(\%conf); | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | # override process to let TT load the templates itself | ||||||||||||||||||||
| 31 | 7 | ▶ | sub process ($self, $template, $vars) | ||||||||||||||||||
|
Subroutine
process: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 32 | { | ||||||||||||||||||||
| 33 | 7 | ▶ | my $pos = ref $template eq 'GLOB' ? tell $template : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 7 | ▶ | $template =~ s{(\..+)?$}{$1 // '.tt' }e | ||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$1 // ".tt"
MC/DC100%1/1
$1 // ".tt"
$1
Truth table100%2/2
A
A= $1
| |||||||||||||||||||||
| 36 | unless ref $template; | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 7 | my $output; | |||||||||||||||||||
| 39 | 7 | ▶ | $self->engine->process($template, $vars, \$output) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | or Gears::X::Template->raise('' . $self->engine->error); | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | # rewind if we were passed a handle | ||||||||||||||||||||
| 43 | 6 | ▶ | seek $template, $pos, 0 | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | if defined $pos; | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 6 | return $output; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||