use more MooseX::Types and support actionattribute in Action vp to explicitly provide...
[catagits/Reaction.git] / lib / Reaction / UI / View / TT.pm
1 package Reaction::UI::View::TT;
2
3 use Reaction::Class;
4 use aliased 'Reaction::UI::View';
5 use Template;
6
7 use namespace::clean -except => [ qw(meta) ];
8 extends View;
9
10
11
12 has '_tt' => (isa => 'Template', is => 'rw', lazy_fail => 1);
13 sub BUILD {
14   my ($self, $args) = @_;
15   my $tt_args = $args->{tt}||{};
16   $self->_tt(Template->new($tt_args));
17 };
18 override 'layout_set_args_for' => sub {
19   my ($self) = @_;
20   return (super(), tt_object => $self->_tt);
21 };
22 sub layout_set_file_extension { 'tt' };
23 sub 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
37
38 1;