Re: [Templates] Pass through perl?
[prev]
[thread]
[next]
[Date index for 2004/07/19]
[% 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.
Another thing that we had problems with were '-' in hash keys.
HASH.gold-1 doesn't work. These are just a couple examples of a lot of
different things we ran into converting.
The conversion has been painful, having to do hugely ugly regexps on our
old template system to convert PERL into TT. I was just thinking it'd
be a LOT easier if we could just somehow use straight PERL in tags
instead of essentially going PERL => TT => PERL.
Here's an example of the process:
We want to print a section if the Product Date is greater than the
current date
What we had in our old templates:
[IF $self->{GLOBAL}->{PRODUCT_DATE}->{'gold-1'} gt $current_date]
What we found to work in TT templates:
[% gold__1 = 'gold-1' %]
[% IF my_gt(GLOBAL.PRODUCT_DATE.${gold__1},current_date) > 0 %]
What I'd like is something like this:
[% IF {% $self->{GLOBAL}->{PRODUCT_DATE}->{'gold-1'} %} {% gt % }
current_date %]
Or:
[% IF [% PERL %]$self->{GLOBAL}->{PRODUCT_DATE}->{'gold-1'} gt
$current_date[% END %] %]
Or maybe:
[% IFP $self->{GLOBAL}->{PRODUCT_DATE}->{'gold-1'} gt $current_date %]
So, basically, I want the full capabilities of PERL available to me in
IF statements..
Hope that's a little clearer.. but of course, it's Monday, so my brain
might not be working yet either :)
Chris
On Fri, 2004-07-16 at 23:21, Simon Wistow wrote:
> > Any other suggestions for translating a lot of random perl code into TT
> > without rewriting a perl interpreter?
>
> I'm not entirely sure what you means but you may want to look at the
> PERL and RAWPERL sections of this
>
> http://www.template-toolkit.org/docs/plain/Manual/Directives.html#Filters_Plugins_Macros_and_Perl
>
> > We've also ran into the fact that gt ge lt and le aren't supported,
> > among other similar seemingly "not supported" issues.
>
> Are you saying that
>
> [% IF var1 >= var2 %]
>
> and
>
> [% IF var1 <= var2 %]
>
> don't work for you?
>
>
> > [% IF {$self->{PRODUCT_AVAILABLE}->{'gold-1'}} {gt} foo %]
> > and have it appear as something like
> > if($self->{PRODUCT_AVAILABLE}->{'gold-1'} gt $stash->GET('foo')) {
>
> Andy may correct me here but to do that I suspect you'd have to subclass
> the Template::Document module and instead of evaluating the Perl
> generated, print it out.
>
> I hope that helps. I confess to being a little confused but it's 7am and
> I'm hungover so I'm hardly in the best shape :)
>
> Simon
>
>
>
> _______________________________________________
> templates mailing list
> templates@xxxxxxxxxxxxxxxx.xxx
> http://lists.template-toolkit.org/mailman/listinfo/templates
--
Chris Huegle <chuegle@xxxxxxxxxxxxxxx.xxx>
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] Pass through perl?
Chris Huegle 18:21 on 19 Jul 2004
|