Re: [Templates] Pass through perl?

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

From: Chris Huegle
Subject: Re: [Templates] Pass through perl?
Date: 19:08 on 20 Jul 2004
On Tue, 2004-07-20 at 04:30, Dave Howorth wrote:
> 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!
> 

It doesn't seem to be.

[% IF 'bar' >= 'foo' %]
translates to
if ('bar' >= 'foo') {
which returns true, since 1 == 1.


> > 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?

In PERL, you quote it: $FOO->{'gold-1'}.  You might notice in the
examples I used below, it is quoted and 'works' in Perl.  In TT,
FOO.'gold-1' is also invalid and there doesn't seem to be a way to quote
it.

>  You have two solutions, change the keys 
> or assign them to variables. Both can be automated, so why worry?
> 

The extensiveness of the systems involed make changing it costly.  

Assigning them to variables increases the complexity significantly,
IMO.  That is what we are doing now, and I'm not particulary happy with
that. 

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

You should try to stay nice when there's a chance you've misunderstood
something.  You'll have more friends that way.

> > 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 %]
> 

That is cleaner, yes, although marginally.

> > 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.
> 

That would also be a functional hack.

> 
> > 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.
> 

We thought it'd be, but didn't encounter a lot of the limitations until
after our testing.

--Chris



_______________________________________________
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