Re: [Templates] Pass through perl?
[prev]
[thread]
[next]
[Date index for 2004/07/20]
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