pass args to ::TT along to all the manually instantiated Template components.
[scpubgit/HTML-String.git] / lib / HTML / String / TT.pm
index 9a6d1dd..f132071 100644 (file)
@@ -18,19 +18,31 @@ use Template;
 use Template::Parser;
 use Template::Stash;
 
+BEGIN {
+  my $orig_blessed = Template::Stash->can('blessed');
+  no warnings 'redefine';
+  *Template::Stash::blessed = sub ($) {
+    my $val = $orig_blessed->($_[0]);
+    return undef if defined($val) and $val eq 'HTML::String::Value';
+    return $val;
+  };
+}
+
 sub new {
     shift;
+    my @args = (ref($_[0]) eq 'HASH' ? %{$_[0]} : @_);
     Template->new(
         PARSER => Template::Parser->new(
-            FACTORY => 'HTML::String::TT::Directive'
+            FACTORY => 'HTML::String::TT::Directive',
+            @args,
         ),
-        STASH => Template::Stash->new,
+        STASH => Template::Stash->new( @args,),
         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]} : @_)
+        @args,
     );
 }