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.


--
Tatsuhiko Miyagawa

Reply via email to