| 1 | package Mojolicious::Plugin::ToolkitRenderer; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Template Toolkit Renderer Mojolicious Plugin | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use 5.016; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Mojo::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | require Template; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | Template->import; | |||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | our $VERSION = '1.15'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=5 SCAR=22.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my ( $self, $app, $settings ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | $settings->{config}{RELATIVE} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$settings->{"config"}{"RELATIVE"} //= 1
MC/DC0%0/1
$settings->{"config"}{"RELATIVE"} //= 1
$settings->{"config"}{"RELATIVE"}
Truth table50%1/2
A
A= $settings->{"config"}{"RELATIVE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | $settings->{config}{EVAL_PERL} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$settings->{"config"}{"EVAL_PERL"} //= 0
MC/DC0%0/1
$settings->{"config"}{"EVAL_PERL"} //= 0
$settings->{"config"}{"EVAL_PERL"}
Truth table50%1/2
A
A= $settings->{"config"}{"EVAL_PERL"}
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | $settings->{config}{INCLUDE_PATH} //= $app->renderer->paths; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$settings->{"config"}{"INCLUDE_PATH"} //= $app->renderer->paths
MC/DC0%0/2
$settings->{"config"}{"INCLUDE_PATH"} //= $app->renderer->paths
$settings->{"config"}{"INCLUDE_PATH"}
$app->renderer->paths
Truth table33%1/3
A //= B
A= $settings->{"config"}{"INCLUDE_PATH"}B= $app->renderer->paths
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $template = Template->new( $settings->{config} ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | $settings->{context}->( $template->context ) if ( $settings->{context} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | $app->renderer->add_handler( tt => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=41.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | my ( $renderer, $controller, $output, $options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | my $inline = $settings->{settings}{inline_template} || 'inline'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$settings->{'settings'}{'inline_template'} || 'inline'
MC/DC0%0/1
$settings->{'settings'}{'inline_template'} || 'inline'
$settings->{'settings'}{'inline_template'}
Truth table50%1/2
A
A= $settings->{'settings'}{'inline_template'}
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | $template->process( | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ( ( $options->{$inline} ) ? \$options->{$inline} : $renderer->template_name($options) ), | ||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | content => $controller->content, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | %{ $controller->stash }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$settings->{'settings'}{'controller'} || 'c'
MC/DC0%0/1
$settings->{'settings'}{'controller'} || 'c'
$settings->{'settings'}{'controller'}
Truth table50%1/2
A
A= $settings->{'settings'}{'controller'}
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | ( $settings->{settings}{controller} || 'c' ) => $controller, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | $output, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | ) || do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ( ref( $settings->{settings}{error_handler} ) eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $settings->{settings}{error_handler}->( $controller, $renderer, $app, $template ); | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$template->error and $template->error eq "file error - exception.html.tt: not found" || $template->error eq 'file error - exception.' . $app->mode . '.html.tt: not found'
$template->error eq "file error - exception.html.tt: not found" or $template->error eq 'file error - exception.' . $app->mode . '.html.tt: not found'
MC/DC0%0/3
$template->error and $template->error eq "file error - exception.html.tt: not found" || $template->error eq 'file error - exception.' . $app->mode . '.html.tt: not found'
$template->error
$template->error eq "file error - exception.html.tt: not found"
$template->error eq 'file error - exception.' . $app->mode . '.html.tt: not found'
Truth table0%0/4
A and B or C
A= $template->errorB= $template->error eq "file error - exception.html.tt: not found"C= $template->error eq 'file error - exception.' . $app->mode . '.html.tt: not found'
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | $template->error and ( | ||||||||||||||||||||||||||||||||||||||||||
| 49 | $template->error eq 'file error - exception.html.tt: not found' or | ||||||||||||||||||||||||||||||||||||||||||
| 50 | $template->error eq 'file error - exception.' . $app->mode . '.html.tt: not found' | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 52 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $$output = $template->error; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $controller->res->headers->content_type('text/plain'); | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $controller->log->error( $template->error ); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $controller->rendered( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$template->error and $template->error =~ /not found/u
MC/DC0%0/2
$template->error and $template->error =~ /not found/u
$template->error
$template->error =~ /not found/u
Truth table0%0/3
A and B
A= $template->errorB= $template->error =~ /not found/u
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | ( $template->error and $template->error =~ /not found/ ) ? 404 : 500 | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | return $$output; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | } ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | $app->helper( | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | render_tt => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | shift->render( handler => 'tt', @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||||||||||||||||