Smells like a TT problem.
The line in question at Template::Stash is reads:

   my $atroot  = ($root eq $self);

This logic exists so such that TT knows if it's looking at the implicit stash context, or a child element in the stash.

The same logic, if I'm not mistaken, in the XS version reads:

   atroot = sv_derived_from(root, TT_STASH_PKG);

So if I change line 685 of Stash.pm to

   my $atroot  = eval { $root->isa(__PACKAGE__) };

Voila!

   [EMAIL PROTECTED] daisuke$ perl test.pl
   # DateTime 0.34
   # Template 2.15
   ok 1 - ok
   ok 2 - ok
   1..2

--d

Tatsuhiko Miyagawa wrote:
Hi,

Passing DateTime object to TT (Template Toolkit) without Stash::XS
built, DateTime overloading gives you an annoying error like
following. (See DATA section for the result on my box.)

Is it something fixable on the user's end, or simply the bug of DateTime, or TT?

#!/usr/bin/perl
use strict;
use warnings;
use DateTime;
use Template;
use Template::Stash;
use Template::Stash::XS;
use Test::More 'no_plan';

diag "DateTime $DateTime::VERSION";
diag "Template $Template::VERSION";

my $tmpl = <<TMPL;
today is [% date.ymd %]
TMPL

for my $stash ( Template::Stash->new, Template::Stash::XS->new ) {
   my $tt = Template->new({ STASH => $stash });
   ok( $tt->process(\$tmpl, { date => DateTime->now }, \my $out),
$tt->error || "ok");
}

__END__
# DateTime 0.30
# Template 2.14
not ok 1 - undef error - Cannot compare a datetime to a regular scalar
at /usr/local/lib/perl/5.8.4/DateTime.pm line 1435.
#
#   Failed test 'undef error - Cannot compare a datetime to a regular
scalar at /usr/local/lib/perl/5.8.4/DateTime.pm line 1435.
# '
#   in /home/miyagawa/tmp/tt-datetime.pl at line 19.
ok 2 - ok
1..2
# Looks like you failed 1 test of 2.



Reply via email to