|
Revision 8345, 1.1 kB
(checked in by tomyhero, 5 years ago)
|
|
lang/perl/OreOre-Starter : fix sample staff
|
| Line | |
|---|
| 1 | package [* module *]::Web::View::TT; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use base 'Catalyst::View::TT::Filters::LazyLoader'; |
|---|
| 5 | use Path::Class; |
|---|
| 6 | use Template::Provider::Encoding; |
|---|
| 7 | use Template::Stash::ForceUTF8; |
|---|
| 8 | |
|---|
| 9 | my $root = [* module *]::Web->config()->{root}->stringify; |
|---|
| 10 | my $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 | |
|---|
| 29 | sub 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 | |
|---|
| 43 | 1; |
|---|
| 44 | |
|---|