Re: [Templates] Template Toolkit and DateTime::Duration
[prev]
[thread]
[next]
[Date index for 2004/12/09]
Hi,
I have gotten a little patch that fixes TT's handling of
DateTime::Duration objects.
In Template::Stash::_do_top() there is a line
my $atroot = ($root eq $self);
which causes the problem. If we replace it with the following, the logic
will short circuit and we will never have to compare apples to oranges.
my $atroot = ((ref ($root) eq ref ($self)) && ($root eq $self));
It should not break anything else. Right?
Arshavir
Arshavir Grigorian wrote:
> Hi,
>
> I am trying to access a DateTime::Duration method from within my TT
> template and getting an getting the following exception:
>
> snip ...
> <td>[% citer.life_left.years %]</td>
> snip ...
>
> where citer.life_left is a DateTime::Duration object.
>
> DateTime::Duration does not overload comparison. See the
> documentation on the compare() method for details. at template.html
> line 28
> eval {...} called at template.html line7
>
> Template::Document::__ANON__('Template::Context=HASH(0x5f3ccc)')
> called at /usr/lib/perl5/site_perl/5.8.4/Template/Document.pm line 155
> ...
>
> DateTime::Duration obviously does not overload comparison operators,
> but where am I comparing anything ? Calling the years() method in the
> Perl code outside the template works fine.
> Another problem is that the line numbers are incorrect (8 lines off).
> Line 28 in my template is a line of static HTML. I had to comment out
> everything to figure out the offending line. What's causing this?
>
> Is the above TT syntax doing something behind the scenes?
>
> Thanks in advance for any pointers.
>
>
> Arshavir
>
> _______________________________________________
> templates mailing list
> templates@xxxxxxxxxxxxxxxx.xxx
> http://lists.template-toolkit.org/mailman/listinfo/templates
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] Template Toolkit and DateTime::Duration
Arshavir Grigorian 19:59 on 09 Dec 2004
|