Re: [Templates] Pass through perl?

[prev] [thread] [next] [Date index for 2004/07/20]

From: Dave Howorth
Subject: Re: [Templates] Pass through perl?
Date: 11:30 on 20 Jul 2004
Chris Huegle wrote:
> [% PERL %] is close, but the main place where we're having the problems
> are within [% IF %] statements.
> 
> >= works, but 'ge' and 'gt' (text comparitors) don't work.

In TT '>=' *is* a text comparison operator!

> Another thing that we had problems with were '-' in hash keys.
> HASH.gold-1 doesn't work.

Well if you look at it, that's obviously an expression 'the gold field 
from HASH minus 1.  The syntax doesn't 'work' in Perl either. Why would 
you expect it to 'work' here?  You have two solutions, change the keys 
or assign them to variables. Both can be automated, so why worry?

It seems to me that a quiet weekend with the Badger book would be 
beneficial.

> What we found to work in TT templates:
> [% gold__1 = 'gold-1' %]
> [% IF my_gt(GLOBAL.PRODUCT_DATE.${gold__1},current_date) > 0 %] 

Why not
[% SET foo = 'gold-1'; IF GLOBAL.PRODUCT_DATE.$foo > current_date %]

> What I'd like is something like this:
> [% IF {% $self->{GLOBAL}->{PRODUCT_DATE}->{'gold-1'} %} {% gt % }
> current_date %]

So (untested):

[% PERL %] $stash->set(foo =>
$self->{GLOBAL}->{PRODUCT_DATE}->{'gold-1'} gt $current_date
) [% END ; IF foo %]

which again is just an automatic template transformation away.


> So, basically, I want the full capabilities of PERL available to me in
> IF statements..

So why not use Perl?  You must believe TT is better for your application 
instead of your existing system, to make it worth doing the transition.

Cheers, Dave


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

[Templates] Pass through perl?
Chris Huegle 01:48 on 17 Jul 2004

Re: [Templates] Pass through perl?
Simon Wistow 06:21 on 17 Jul 2004

Re: [Templates] Pass through perl?
Chris Huegle 18:21 on 19 Jul 2004

Re: [Templates] Pass through perl?
Dave Howorth 11:30 on 20 Jul 2004

Re: [Templates] Pass through perl?
Chris Huegle 19:08 on 20 Jul 2004

Re: [Templates] Pass through perl?
Andy Wardley 07:52 on 21 Jul 2004

Re: [Templates] Pass through perl?
Dave Howorth 09:13 on 21 Jul 2004

Re: [Templates] Pass through perl?
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 08:59 on 05 Aug 2004

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