root/branches/hackathon-summary/plagger/lib/Plagger/Template.pm

Revision 1412 (checked in by miyagawa, 2 years ago)

Now assets_path: can be localized per plugins.

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Template;
2 use strict;
3 use base qw( Template );
4
5 use FindBin;
6 use File::Spec::Functions qw(catfile);
7
8 use Template::Provider::Encoding 0.04;
9 use Template::Stash::ForceUTF8;
10
11 sub new {
12     my($class, $context, $plugin) = @_;
13
14     my $path = $context->conf->{assets_path} || catfile($FindBin::Bin, "assets");
15     my $paths = [ catfile($path, "plugins", $plugin->class_id),
16                   catfile($path, "common") ];
17
18     if ($plugin->conf->{assets_path}) {
19         unshift @$paths, $plugin->conf->{assets_path};
20     }
21
22     return $class->SUPER::new({
23         INCLUDE_PATH => $paths,
24         LOAD_TEMPLATES => [
25             Template::Provider::Encoding->new({ INCLUDE_PATH => $paths }),
26         ],
27         STASH => Template::Stash::ForceUTF8->new,
28         PLUGIN_BASE => [ 'Plagger::TT' ],
29     });
30 }
31
32 1;
33
Note: See TracBrowser for help on using the browser.