r20898@agaton (orig r755): wreis | 2008-07-24 00:32:56 +0100
[catagits/Reaction.git] / lib / Reaction / UI / View / TT.pm
CommitLineData
7adfd53f 1package Reaction::UI::View::TT;
2
3use Reaction::Class;
4use aliased 'Reaction::UI::View';
5use Template;
6
7class TT is View, which {
8
9 has '_tt' => (isa => 'Template', is => 'rw', lazy_fail => 1);
10
11 implements 'BUILD' => as {
12 my ($self, $args) = @_;
13 my $tt_args = $args->{tt}||{};
14 $self->_tt(Template->new($tt_args));
15 };
16
17 overrides 'layout_set_args_for' => sub {
18 my ($self) = @_;
19 return (super(), tt_object => $self->_tt);
20 };
21
349a57a4 22 implements layout_set_file_extension => as { 'tt' };
23
7adfd53f 24 implements 'serve_static_file' => as {
25 my ($self, $c, $args) = @_;
26 foreach my $path (@{$self->search_path_for_type('web')}) {
27 my $cand = $path->file(@$args);
28 if ($cand->stat) {
29 $c->serve_static_file($cand);
30 return 1;
31 }
32 }
33 return 0;
34 };
35
36};
37
381;