Permalink
Browse files

filterの定義をconfから

  • Loading branch information...
1 parent 982b11f commit a3934aed545298637ca1a6ba8ea9e1e1a2e3f74c @nekokak committed Oct 6, 2009
Showing with 15 additions and 4 deletions.
  1. +14 −0 eg/config.pl
  2. +1 −4 lib/Kamui/View/TT.pm
View
@@ -1,6 +1,9 @@
use Kamui;
use MyAPP::Container;
use Path::Class;
+use HTML::Entities;
+use Encode;
+use URI::Escape;
my $home = container('home');
@@ -9,6 +12,16 @@
tt => +{
path => $home->file('assets/tmpl')->stringify,
options => '',
+ filters => +{
+ html_unescape => sub {
+ HTML::Entities::decode_entities(shift);
+ },
+ uri => sub{
+ Encode::is_utf8( $_[0] )
+ ? URI::Escape::uri_escape_utf8($_[0])
+ : URI::Escape::uri_escape($_[0]);
+ },
+ },
},
json => +{
stash_key => 'json',
@@ -27,3 +40,4 @@
},
},
};
+
View
@@ -4,7 +4,6 @@ use base 'Kamui::View';
use Template;
use File::Spec;
use Template::Stash::EscapeHTML;
-use HTML::Entities;
use String::CamelCase qw/decamelize/;
use Encode;
@@ -18,9 +17,7 @@ sub render {
RELATIVE => 1,
ENCODING => 'utf-8',
STASH => Template::Stash::EscapeHTML->new,
- FILTERS => +{
- html_unescape => sub { HTML::Entities::decode_entities(shift) },
- },
+ FILTERS => $context->conf->{view}->{tt}->{filters},
COMPILE_DIR => '/tmp/' . $ENV{USER} . "/",
INCLUDE_PATH => [ '.', File::Spec->catfile($context->conf->{view}->{tt}->{path}) ],
%{ $context->conf->{view}->{tt}->{options} || {} },

0 comments on commit a3934ae

Please sign in to comment.