initial refactor of CRUD controller actions as roles
[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
81393881 7use namespace::clean -except => [ qw(meta) ];
8extends View;
9
7adfd53f 10
81393881 11
12has '_tt' => (isa => 'Template', is => 'rw', lazy_fail => 1);
13sub BUILD {
14 my ($self, $args) = @_;
15 my $tt_args = $args->{tt}||{};
16 $self->_tt(Template->new($tt_args));
17};
18override 'layout_set_args_for' => sub {
19 my ($self) = @_;
20 return (super(), tt_object => $self->_tt);
7adfd53f 21};
81393881 22sub layout_set_file_extension { 'tt' };
23sub serve_static_file {
24 my ($self, $c, $args) = @_;
25 foreach my $path (@{$self->search_path_for_type('web')}) {
26 my $cand = $path->file(@$args);
27 if ($cand->stat) {
28 $c->serve_static_file($cand);
29 return 1;
30 }
31 }
32 return 0;
33};
34
35__PACKAGE__->meta->make_immutable;
36
7adfd53f 37
381;