6e35360acb8196715e344da95bad7d76ca87768c
[scpubgit/HTML-String.git] / lib / HTML / String / TT.pm
1 package HTML::String::TT;
2
3 use strictures 1;
4
5 use HTML::String;
6 use HTML::String::TT::Directive;
7 use Safe::Isa;
8 use Template;
9 use Template::Parser;
10 use Template::Stash;
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,
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         } },
24         (ref($_[0]) eq 'HASH' ? %{$_[0]} : @_)
25     );
26 }
27
28 1;