use UNIVERSAL::ref to make TT internals be less stupid
[scpubgit/HTML-String.git] / lib / HTML / String / TT.pm
CommitLineData
ed99cbb4 1package HTML::String::TT;
2
3use strictures 1;
51eaef0b 4
586054e0 5BEGIN {
6 if ($INC{"Template.pm"} and !$INC{"UNIVERSAL/ref.pm"}) {
7 warn "Template was loaded before we could load UNIVERSAL::ref"
8 ." - this means you're probably going to get weird errors."
9 ." To avoid this, use HTML::String::TT before loading Template."
10 }
11 require UNIVERSAL::ref;
12}
13
51eaef0b 14use HTML::String;
15use HTML::String::TT::Directive;
16use Safe::Isa;
ed99cbb4 17use Template;
18use Template::Parser;
19use Template::Stash;
ed99cbb4 20
21sub new {
22 shift;
23 Template->new(
24 PARSER => Template::Parser->new(
25 FACTORY => 'HTML::String::TT::Directive'
26 ),
27 STASH => Template::Stash->new,
51eaef0b 28 FILTERS => { no_escape => sub {
29 $_[0]->$_isa('HTML::String::Value')
30 ? HTML::String::Value->new(map $_->[0], @{$_[0]->{parts}})
31 : HTML::String::Value->new($_)
32 } },
77724961 33 (ref($_[0]) eq 'HASH' ? %{$_[0]} : @_)
ed99cbb4 34 );
35}
36
371;