| 1 | package MooseX::Templated::View::TT; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | MooseX::Templated::View::TT - Template Toolkit View for MooseX::Templated | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | See L<MooseX::Templated::View> | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 | with 'MooseX::Templated::View'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 4 | my %TT_DEFAULT_CONFIG = ( | |||||||||||||||||||||||||||
| 21 | 'ABSOLUTE' => 1, # required for using default module name | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head2 build_default_template_suffix | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 3 | ▶ | sub build_default_template_suffix { '.tt' } | ||||||||||||||||||||||||||
|
Subroutine
build_default_template_suffix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head2 build_renderer | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 3 | ▶ | sub build_renderer { | ||||||||||||||||||||||||||
|
Subroutine
build_renderer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 36 | 3 | return Template->new( %TT_DEFAULT_CONFIG ); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =head2 process( $source, $model ) | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | Processes the model using the TT source and returns the output as a string | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 13 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=5 SCAR=17.5
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 13 | my ($self, $source, $model) = @_; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 13 | ▶ | croak "! Error: expected 'source'" unless $source; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 13 | ▶ | croak "! Error: expected 'model' to be Moose object" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$model and builtin::blessed($model)
MC/DC0%0/2
$model and builtin::blessed($model)
$model
builtin::blessed($model)
Truth table33%1/3
A and B
A= $modelB= builtin::blessed($model)
| |||||||||||||||||||||||||||||
| 50 | if ( ! $model || ! blessed $model ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 13 | my $tt_output = ''; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 13 | my %stash = ( self => $model ); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 13 | ▶ | $self->renderer->process( \$source, \%stash, \$tt_output ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | or croak( "couldn't process template (module: ".($self->view_class).")\n". | ||||||||||||||||||||||||||||
| 58 | "\t".$self->renderer->error() ); | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 13 | return $tt_output; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 4 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||