no_escape filter for TT
[scpubgit/HTML-String.git] / lib / HTML / String / TT.pm
index 90b1ec5..6e35360 100644 (file)
@@ -1,10 +1,13 @@
 package HTML::String::TT;
 
 use strictures 1;
+
+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,6 +16,11 @@ 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]} : @_)
     );
 }