Gentlemen,

I have been using Template::Toolkit for many years and always used
Stash::XS. Recently, I tried to make my application work on a windows
machine which didn't have Stash::XS, so I used the pure perl Stash. This
uncovered some unexpected behavior changes which are also evident on
Unix machines.

Here is some sample code:

#!/usr/bin/perl
use strict;

use Template;
use Template::Config;

$Template::Config::STASH='Template::Stash'; # Force use of perl Stash

my $template=Template->new;

my $foo={bar=>'bloarg'};
bless $foo,"Something";



my $file=<<"EOT";

[% foo.bar='baz' %]

bar=[% foo.bar %]

EOT


$template->process(\$file,{foo=>$foo});

$_ and print "error: $_" for $template->error();





What this code does, is force the use of the perl Stash, and tries to
pass "foo" as a blessed hash ref. Because it is blessed, Stash.pm
doesn't think its a HASH and tries to call method bar, instead of
setting the named value bar. Stash::XS doesn't know its blessed and 
works as expected.

Changing $Template::Config::STASH to "Template::Stash::XS" makes the
error go away.

I don't want to unbless my references, because I do cool stuff with them
inside the templates. 

Any thoughts?

-David Graves



_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to