Commit | Line | Data |
7adfd53f |
1 | package Reaction::UI::View::TT; |
2 | |
3 | use Reaction::Class; |
4 | use aliased 'Reaction::UI::View'; |
5 | use Template; |
6 | |
7 | class 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 | |
38 | 1; |