| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::TemplateServer::Provider::TT; |
|
2
|
1
|
|
|
1
|
|
25906
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Template; |
|
4
|
|
|
|
|
|
|
use Method::Signatures; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with 'App::TemplateServer::Provider::Filesystem'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'engine' => ( |
|
9
|
|
|
|
|
|
|
is => 'ro', |
|
10
|
|
|
|
|
|
|
isa => 'Template', |
|
11
|
|
|
|
|
|
|
default => sub { Template->new({ INCLUDE_PATH => [shift->docroot] }) }, |
|
12
|
|
|
|
|
|
|
lazy => 1, |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
method render_template($template, $context) { |
|
16
|
|
|
|
|
|
|
my $out; |
|
17
|
|
|
|
|
|
|
$self->engine->process($template, $context->data, \$out) |
|
18
|
|
|
|
|
|
|
or die "Failed to render: ". $self->engine->error; |
|
19
|
|
|
|
|
|
|
return $out; |
|
20
|
|
|
|
|
|
|
}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
App::TemplateServer::Provider::TT - Template Toolkit template provider for App::TemplateServer |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $provider = App::TemplateServer::Provider::TT->new( |
|
33
|
|
|
|
|
|
|
docroot => ['/path/to/TT/templates'] |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my @templates = $provider->list_templates; |
|
37
|
|
|
|
|
|
|
my $foo = $provider->render_template('/what/ever/foo.tt'); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
These methods implement the C<App::TemplateServer::Provider> role. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 list_templates |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 render_template |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|