| 1 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | package MojoX::Renderer::Alloy::Tmpl; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | $MojoX::Renderer::Alloy::Tmpl::AUTHORITY = 'cpan:AJGB'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | } | ||||||||||||||||||||||||||||||||||||||||||
| 7 | { | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | $MojoX::Renderer::Alloy::Tmpl::VERSION = '1.121150'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||||||
| 10 | #ABSTRACT: Template::Alloy's Text::Tmpl renderer | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use base 'MojoX::Renderer::Alloy'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Template::Alloy qw( Tmpl ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | __PACKAGE__->attr('alloy'); | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub _init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my %config = ( | |||||||||||||||||||||||||||||||||||||||||
| 23 | START_TAG => '#[', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | END_TAG => ']#', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | $self->_default_config(@_), | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $alloy = Template::Alloy->new( | |||||||||||||||||||||||||||||||||||||||||
| 29 | %config, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | $alloy->set_dir( $config{INCLUDE_PATH} ) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if exists $config{INCLUDE_PATH}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $alloy->set_delimiters(@config{qw(START_TAG END_TAG)}); | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $self->alloy( $alloy ); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub _render { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my ($self, $r, $c, $output, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $inline = $options->{inline}; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $tname = $r->template_name($options); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $path = $r->template_path($options); | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return unless defined $inline || ( defined $path && defined $tname ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $inline or defined $path and defined $tname
defined $path and defined $tname
MC/DC0%0/3
defined $inline or defined $path and defined $tname
defined $inline
defined $path
defined $tname
Truth table0%0/4
A or B and C
A= defined $inlineB= defined $pathC= defined $tname
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $method; | |||||||||||||||||||||||||||||||||||||||||
| 51 | # inline | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ( defined $inline ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $method = 'parse_string'; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $path = $inline; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # regular file | ||||||||||||||||||||||||||||||||||||||||||
| 57 | elsif ( -r $path ) { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $method = 'parse_file'; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # inlined templates are not supported | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( $r->get_data_template($options, $tname) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $c->render_exception( | |||||||||||||||||||||||||||||||||||||||||
| 63 | "Inlined templates are not supported" | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $c->render_not_found( $tname ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $alloy = $self->alloy; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $alloy->set_values( | |||||||||||||||||||||||||||||||||||||||||
| 73 | $self->_template_vars( $c ) | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $$output = $alloy->$method( $path ); | |||||||||||||||||||||||||||||||||||||||||
| 78 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ( my $e = $alloy->error || $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$alloy->error || $@
MC/DC0%0/2
$alloy->error || $@
$alloy->error
$@
Truth table0%0/3
A || B
A= $alloy->errorB= $@
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | chomp $e; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $c->render_exception( $e ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 84 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||||||||||||||||