Re[2]: [Templates] Can't comparing strings (strings are treated as numbers)

[prev] [thread] [next] [Date index for 2004/12/23]

From: Oleg Burlaca
Subject: Re[2]: [Templates] Can't comparing strings (strings are treated as numbers)
Date: 21:15 on 23 Dec 2004
> If you need this kind of thing often enough, you could define lt (and
> gt, for that matter) as function refs in your perl script and pass them
> in as variables:
>
> #!/usr/bin/perl
> use Template;
>
> my $func = {
>         'lt' => sub { $_[0] lt %_[1] },
>         'gt' => sub { $_[0] gt %_[1] },
> };
>
> my $tt = Template->>new();
> local $/ = undef;
> $tt->>process(<DATA>, $func);
>
> __DATA__
> [% IF func.lt('2004-11-23', '2004-11-26') %]
> Good
> [% END %]

Thanks, Jason. I've added 'eq', 'lt', 'gt' in my script.
Interesting, why these functions are not part of the TT,
maybe it involves to hack the parser a lot ?
Besides this tiny awkwardness, I'm very pleased with TT :)

Thanks all.


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

Re[2]: [Templates] Can't comparing strings (strings are treated as numbers)
Oleg Burlaca 21:15 on 23 Dec 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52