X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FString%2FTT.pm;h=9a6d1dd5638bd739abf429a6d77f427729c310fc;hb=d86bdf828539c046cbc09d5073897bf24862c93d;hp=fb1f1cb9df02ef0acf1b95649eca6a7411136818;hpb=ed99cbb44b0589b147076f6874c331818db44b83;p=scpubgit%2FHTML-String.git diff --git a/lib/HTML/String/TT.pm b/lib/HTML/String/TT.pm index fb1f1cb..9a6d1dd 100644 --- a/lib/HTML/String/TT.pm +++ b/lib/HTML/String/TT.pm @@ -1,10 +1,22 @@ package HTML::String::TT; use strictures 1; + +BEGIN { + if ($INC{"Template.pm"} and !$INC{"UNIVERSAL/ref.pm"}) { + warn "Template was loaded before we could load UNIVERSAL::ref" + ." - this means you're probably going to get weird errors." + ." To avoid this, use HTML::String::TT before loading Template." + } + require UNIVERSAL::ref; +} + +use HTML::String; +use HTML::String::TT::Directive; +use Safe::Isa; use Template; use Template::Parser; use Template::Stash; -use HTML::String::TT::Directive; sub new { shift; @@ -13,8 +25,107 @@ sub new { FACTORY => 'HTML::String::TT::Directive' ), STASH => Template::Stash->new, - @_ + FILTERS => { no_escape => sub { + $_[0]->$_isa('HTML::String::Value') + ? HTML::String::Value->new(map $_->[0], @{$_[0]->{parts}}) + : HTML::String::Value->new($_) + } }, + (ref($_[0]) eq 'HASH' ? %{$_[0]} : @_) ); } 1; + +__END__ + +=head1 NAME + +HTML::String::TT - HTML string auto-escaping for L