Corion has asked for the wisdom of the Perl Monks concerning the following question:
I am most likely looking in the wrong places and have missed some crucial piece of information. I can't get DateTime objects to play well with Template::Stash - the Template::Stash seems to want to compare the DateTime object against the template root, but the DateTime object does not want to be compared with anything other than a DateTime object, or something sufficiently similar. See my code below - it is some convoluted way of printing todays date, except it doesn't:
use strict; use DateTime; use Template; my $config = {}; my $template = Template->new($config); my $input = \'[% calendar.ymd(".") %]'; # process input template, substituting variables $template->process($input, { calendar => DateTime->now }) or die $template->error();
After patching DateTime.pm so it gives some better error diagnostics, I get
undef error - Cannot compare a datetime to a regular scalar (2005-02-2 +8T21:51:58 / Template::Stash=HASH(0x2048a14)) at c:/perl/site/5.8.5/l +ib/Template/Stash.pm line 582
but I don't want to believe that nobody has used Template::Toolkit and DateTime together, so the error must be somewhere in my usage of one of the two.
Update: DateTime v0.28, Template::Toolkit 2.14
Update 2: I hacked myself a workaround by removing the overloaded string comparison of DateTime. This is horribly ugly and there must be a better way :-(