line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ark::View::Xslate; |
2
|
1
|
|
|
1
|
|
379
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
4
|
1
|
|
|
1
|
|
4
|
use Ark 'View'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
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
|
2
|
my ($self, $template) = @_; |
48
|
1
|
|
|
|
|
3
|
$self->context->stash->{__view_xslate_template} = $template; |
49
|
1
|
|
|
|
|
2
|
$self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub render { |
53
|
4
|
|
|
4
|
0
|
91
|
my $self = shift; |
54
|
4
|
|
|
|
|
4
|
my $template = shift; |
55
|
4
|
|
|
|
|
13
|
my $context = $self->context; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$template ||= $self->context->stash->{__view_xslate_template} |
58
|
4
|
50
|
66
|
|
|
69
|
|| $self->context->request->action->reverse |
|
|
|
66
|
|
|
|
|
59
|
|
|
|
|
|
|
or return; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->xslate->render( |
62
|
|
|
|
|
|
|
$template . $self->extension, |
63
|
|
|
|
|
|
|
{ |
64
|
4
|
|
|
|
|
76
|
%{ $context->stash }, |
|
4
|
|
|
|
|
924
|
|
65
|
|
|
|
|
|
|
c => $self->context, |
66
|
|
|
|
|
|
|
@_, |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub process { |
72
|
3
|
|
|
3
|
0
|
5
|
my ($self, $c) = @_; |
73
|
3
|
|
|
|
|
15
|
$c->response->body( $self->render ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |