| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ark::View::Xslate; |
|
2
|
1
|
|
|
1
|
|
483
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
27
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use Ark 'View'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has path => ( |
|
7
|
|
|
|
|
|
|
is => 'rw', |
|
8
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
9
|
|
|
|
|
|
|
lazy => 1, |
|
10
|
|
|
|
|
|
|
default => sub { |
|
11
|
|
|
|
|
|
|
my $self = shift; |
|
12
|
|
|
|
|
|
|
[$self->path_to('root')]; |
|
13
|
|
|
|
|
|
|
}, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has options => ( |
|
17
|
|
|
|
|
|
|
is => 'rw', |
|
18
|
|
|
|
|
|
|
isa => 'HashRef', |
|
19
|
|
|
|
|
|
|
lazy => 1, |
|
20
|
|
|
|
|
|
|
default => sub { {} }, |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has extension => ( |
|
24
|
|
|
|
|
|
|
is => 'rw', |
|
25
|
|
|
|
|
|
|
isa => 'Str', |
|
26
|
|
|
|
|
|
|
default => '.tx', |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has xslate => ( |
|
30
|
|
|
|
|
|
|
is => 'rw', |
|
31
|
|
|
|
|
|
|
isa => 'Text::Xslate', |
|
32
|
|
|
|
|
|
|
lazy => 1, |
|
33
|
|
|
|
|
|
|
default => sub { |
|
34
|
|
|
|
|
|
|
my $self = shift; |
|
35
|
|
|
|
|
|
|
my $c = sub { $self->context }; |
|
36
|
|
|
|
|
|
|
my $stash = sub { $self->context->stash }; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$self->ensure_class_loaded('Text::Xslate'); |
|
39
|
|
|
|
|
|
|
Text::Xslate->new( |
|
40
|
|
|
|
|
|
|
path => $self->path, |
|
41
|
|
|
|
|
|
|
%{ $self->options } |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
}, |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub template { |
|
47
|
1
|
|
|
1
|
0
|
4
|
my ($self, $template) = @_; |
|
48
|
1
|
|
|
|
|
4
|
$self->context->stash->{__view_xslate_template} = $template; |
|
49
|
1
|
|
|
|
|
3
|
$self; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub render { |
|
53
|
4
|
|
|
4
|
0
|
122
|
my $self = shift; |
|
54
|
4
|
|
|
|
|
8
|
my $template = shift; |
|
55
|
4
|
|
|
|
|
20
|
my $context = $self->context; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$template ||= $self->context->stash->{__view_xslate_template} |
|
58
|
4
|
50
|
66
|
|
|
100
|
|| $self->context->request->action->reverse |
|
|
|
|
66
|
|
|
|
|
|
59
|
|
|
|
|
|
|
or return; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->xslate->render( |
|
62
|
|
|
|
|
|
|
$template . $self->extension, |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
4
|
|
|
|
|
102
|
%{ $context->stash }, |
|
|
4
|
|
|
|
|
1307
|
|
|
65
|
|
|
|
|
|
|
c => $self->context, |
|
66
|
|
|
|
|
|
|
@_, |
|
67
|
|
|
|
|
|
|
}, |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub process { |
|
72
|
3
|
|
|
3
|
0
|
9
|
my ($self, $c) = @_; |
|
73
|
3
|
|
|
|
|
48
|
$c->response->body( $self->render ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |