Commit | Line | Data |
ed99cbb4 |
1 | package HTML::String::TT; |
2 | |
3 | use strictures 1; |
51eaef0b |
4 | |
5 | use HTML::String; |
6 | use HTML::String::TT::Directive; |
7 | use Safe::Isa; |
ed99cbb4 |
8 | use Template; |
9 | use Template::Parser; |
10 | use Template::Stash; |
ed99cbb4 |
11 | |
12 | sub new { |
13 | shift; |
14 | Template->new( |
15 | PARSER => Template::Parser->new( |
16 | FACTORY => 'HTML::String::TT::Directive' |
17 | ), |
18 | STASH => Template::Stash->new, |
51eaef0b |
19 | FILTERS => { no_escape => sub { |
20 | $_[0]->$_isa('HTML::String::Value') |
21 | ? HTML::String::Value->new(map $_->[0], @{$_[0]->{parts}}) |
22 | : HTML::String::Value->new($_) |
23 | } }, |
77724961 |
24 | (ref($_[0]) eq 'HASH' ? %{$_[0]} : @_) |
ed99cbb4 |
25 | ); |
26 | } |
27 | |
28 | 1; |