root/lang/perl/OreOre-Starter/trunk/sample/skel/oreore-catalyst/lib/__module__/Web/View/TT.pm @ 8345

Revision 8345, 1.1 kB (checked in by tomyhero, 6 years ago)

lang/perl/OreOre-Starter : fix sample staff

Line 
1package [* module *]::Web::View::TT;
2
3use strict;
4use base 'Catalyst::View::TT::Filters::LazyLoader';
5use Path::Class;
6use Template::Provider::Encoding;
7use Template::Stash::ForceUTF8;
8
9my $root = [* module *]::Web->config()->{root}->stringify;
10my $common = Path::Class::dir( $root, 'common' )->stringify;
11
12__PACKAGE__->config(
13    FILTERS_LAZYLOADER => {
14        lib_path =>  [* module *]::Web->path_to('lib'),
15        pkg => '[* module *]::Web::TTFilters',
16    },
17    TEMPLATE_EXTENSION => '.tt',
18    LOAD_TEMPLATES     => [
19        Template::Provider::Encoding->new( INCLUDE_PATH => $root ),
20        Template::Provider::Encoding->new( INCLUDE_PATH => $common ),
21    ],
22    STASH      => Template::Stash::ForceUTF8->new,
23    PREFIX_MAP => {
24        default => 0,
25        common  => 1,
26    },
27);
28
29sub process {
30    my ( $self, $c ) = @_;
31
32    unless ( $c->res->content_type ) {
33        my $agent = $c->req->user_agent || '';
34        $c->res->content_type(
35            $agent =~ /MSIE/
36            ? 'text/html; charset=utf-8'
37            : 'application/xhtml+xml; charset=utf-8'
38        );
39    }
40    $self->SUPER::process($c);
41}
42
431;
44
Note: See TracBrowser for help on using the browser.