blob: 46d31355586db2fdd22b80ef2596f6865db49544 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package Reaction::UI::View::TT;
use Reaction::Class;
use aliased 'Reaction::UI::View';
use Template;
class TT is View, which {
has '_tt' => (isa => 'Template', is => 'rw', lazy_fail => 1);
implements 'BUILD' => as {
my ($self, $args) = @_;
my $tt_args = $args->{tt}||{};
$self->_tt(Template->new($tt_args));
};
overrides 'layout_set_args_for' => sub {
my ($self) = @_;
return (super(), tt_object => $self->_tt);
};
overrides 'rendering_context_args_for' => sub {
my ($self, %args) = @_;
return ();
};
implements 'serve_static_file' => as {
my ($self, $c, $args) = @_;
foreach my $path (@{$self->search_path_for_type('web')}) {
my $cand = $path->file(@$args);
if ($cand->stat) {
$c->serve_static_file($cand);
return 1;
}
}
return 0;
};
};
1;
|