Pickles/View/Xslate.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 42 CC 4 SCAR 24.0
CC
4
Cov
0%
render
20.0
new
2.0
BEGIN
2.0
CRAP 11.0
1 package Pickles::View::Xslate;
2 use strict;
3 use base qw(Pickles::View);
4 use Text::Xslate;
5  
6 my $tx;
7  
8 sub new {
9 my $class = shift;
10 my $self = bless {}, $class;
11 $self;
12 }
13  
14 sub render {
15 my( $self, $c ) = @_;
16 my $tx = $self->{xslate};
17 if (! $tx) {
18 my $config = $self->merge_config( $c );
19 $tx = $self->{xslate} = Text::Xslate->new(
20 path => [
21 $c->config->path_to('view'),
22 $c->config->path_to('view', 'inc'),
23 ],
24 %{$config},
25 $ENV{PLACK_ENV} eq 'production' ? ( cache => 1 ) : (),
26 );
27 }
28 my $template = $c->stash->{'VIEW_TEMPLATE'};
29 my $suffix = $tx->{suffix};
30 unless ( $template =~ /$suffix$/ ) {
31 $template .= $suffix;
32 }
33 my %vars = (
34 %{$c->stash},
35 c => $c,
36 );
37 my $output = $tx->render( $template, \%vars );
38 return $output;
39 }
40  
41 1;
42  
43 __END__