| 1 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | package MojoX::Renderer::Alloy; | ||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 10 | $MojoX::Renderer::Alloy::AUTHORITY = 'cpan:AJGB'; | |||||||||||||||||||||||||||||||||||||
| 6 | } | ||||||||||||||||||||||||||||||||||||||
| 7 | { | ||||||||||||||||||||||||||||||||||||||
| 8 | 10 | $MojoX::Renderer::Alloy::VERSION = '1.121150'; | |||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||
| 10 | #ABSTRACT: Base class for Template::Alloy renderer | ||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use base 'Mojo::Base'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub build { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | die "Abstract class cannot be built" | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 20 | if ref $self eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | 0 | $self->_init(@_); | |||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return sub { $self->_render(@_) }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub _init { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $self->alloy( | |||||||||||||||||||||||||||||||||||||
| 31 | Template::Alloy->new( $self->_default_config(@_) ) | ||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub _default_config { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_config: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $app = delete $args{app} || delete $args{mojo}; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
delete $args{'app'} || delete $args{'mojo'}
MC/DC0%0/2
delete $args{'app'} || delete $args{'mojo'}
delete $args{'app'}
delete $args{'mojo'}
Truth table0%0/3
A || B
A= delete $args{'app'}B= delete $args{'mojo'}
| |||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $compile_dir = defined $app && $app->home->rel_dir('tmp/ctpl'); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $app && $app->home->rel_dir('tmp/ctpl')
MC/DC0%0/2
defined $app && $app->home->rel_dir('tmp/ctpl')
defined $app
$app->home->rel_dir('tmp/ctpl')
Truth table0%0/3
A && B
A= defined $appB= $app->home->rel_dir('tmp/ctpl')
| |||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $inc_path = defined $app && $app->home->rel_dir('templates'); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $app && $app->home->rel_dir('templates')
MC/DC0%0/2
defined $app && $app->home->rel_dir('templates')
defined $app
$app->home->rel_dir('templates')
Truth table0%0/3
A && B
A= defined $appB= $app->home->rel_dir('templates')
| |||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | return ( | ||||||||||||||||||||||||||||||||||||||
| 44 | ( | ||||||||||||||||||||||||||||||||||||||
| 45 | $inc_path ? | ||||||||||||||||||||||||||||||||||||||
| 46 | ( | ||||||||||||||||||||||||||||||||||||||
| 47 | INCLUDE_PATH => $inc_path | ||||||||||||||||||||||||||||||||||||||
| 48 | ) : () | ||||||||||||||||||||||||||||||||||||||
| 49 | ), | ||||||||||||||||||||||||||||||||||||||
| 50 | COMPILE_EXT => '.ct', | ||||||||||||||||||||||||||||||||||||||
| 51 | COMPILE_DIR => ( $compile_dir || File::Spec->tmpdir ), | ||||||||||||||||||||||||||||||||||||||
| 52 | UNICODE => 1, | ||||||||||||||||||||||||||||||||||||||
| 53 | ENCODING => 'utf-8', | ||||||||||||||||||||||||||||||||||||||
| 54 | CACHE_SIZE => 128, | ||||||||||||||||||||||||||||||||||||||
| 55 | RELATIVE => 1, | ||||||||||||||||||||||||||||||||||||||
| 56 | ABSOLUTE => 1, | ||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | %{ $args{template_options} || {} }, | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$compile_dir || 'File::Spec'->tmpdir
$args{'template_options'} || {}
MC/DC0%0/2
$compile_dir || 'File::Spec'->tmpdir
$compile_dir
'File::Spec'->tmpdir
MC/DC0%0/1
$args{'template_options'} || {}
$args{'template_options'}
Truth table0%0/3
A || B
A= $compile_dirB= 'File::Spec'->tmpdir
Truth table0%0/2
A
A= $args{'template_options'}
| |||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub _get_input { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_input: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ( $self, $r, $c, $options ) = @_; | |||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $inline = $options->{inline}; | |||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $tname = $r->template_name($options); | |||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $path = $r->template_path($options); | |||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $path = \$inline if defined $inline; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return unless defined $path && defined $tname; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $path and defined $tname
MC/DC0%0/2
defined $path and defined $tname
defined $path
defined $tname
Truth table0%0/3
A and B
A= defined $pathB= defined $tname
| |||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | return ref $path ? $path # inline | ||||||||||||||||||||||||||||||||||||||
| 74 | : -r $path ? | ||||||||||||||||||||||||||||||||||||||
| 75 | $path # regular file | ||||||||||||||||||||||||||||||||||||||
| 76 | : | ||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | do { # inlined templates are not supported | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( $r->get_data_template($options, $tname) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $c->render_exception( | |||||||||||||||||||||||||||||||||||||
| 80 | "Inlined templates are not supported" | ||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||
| 82 | } else { | ||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $c->render_not_found( $tname ); | |||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 86 | }; | ||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub _template_vars { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_template_vars: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my ($self, $c) = @_; | |||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $helper = MojoX::Renderer::Alloy::Helper->new(ctx => $c); | |||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | # allows to overwrite "h" | ||||||||||||||||||||||||||||||||||||||
| 95 | return { | ||||||||||||||||||||||||||||||||||||||
| 96 | h => $helper, | ||||||||||||||||||||||||||||||||||||||
| 97 | 0 | %{ $c->stash }, | |||||||||||||||||||||||||||||||||||||
| 98 | c => $c, | ||||||||||||||||||||||||||||||||||||||
| 99 | }, | ||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||
| 102 | # stolen from MojoX::Renderer::TT | ||||||||||||||||||||||||||||||||||||||
| 103 | package | ||||||||||||||||||||||||||||||||||||||
| 104 | MojoX::Renderer::Alloy::Helper; | ||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||
| 106 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 107 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | 10 | ▶ | use base 'Mojo::Base'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||
| 111 | 10 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||
| 113 | 10 | __PACKAGE__->attr('ctx'); | |||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $method = $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | return if $method =~ /^[A-Z]+?$/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | return if $method =~ /^_/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return if $method =~ /(?:\:*?)DESTROY$/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $method = (split '::' => $method)[-1]; | |||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | die qq/Unknown helper: $method/ unless $self->ctx->app->renderer->helpers->{$method}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return $self->ctx->$method(@_); | |||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||
| 131 | 10 | 1; | |||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||
| 134 | __END__ | ||||||||||||||||||||||||||||||||||||||