Thanks Thompson,
I've tried it and no success.
Please note that I can get the results by trying:
[% result("a", "1", "b", "2") %] and [% result("a", 1, "b", 2) %]
No need to specific VARIABLES. and double quotes are not matter in this
case.
I think there should be some blanket styles to handle this.
Thanks in advance,
Chakkit
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 02, 2008 7:09 PM
To: Chakkit Ngamsom
Subject: Re: [Templates] Passing hashes to Perl
It seems that your problem is with the dot operator.
I think it should be:
(in template)
[% VARIABLES.result( a=>"1", b => "2") %]
Also I believe you are "stringifying" the numbers by including the double
quotes.
Try it winthout the double quotes.
[% VARIABLES.result(a => 1, b => 2) %]
Hope it helps!
On Nov 2, 2008 1:47am, Chakkit Ngamsom <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> Hi All,
>
>
>
>
>
> Can someone please let me know how to pass hashes from
> template to Perl?
>
>
>
>
>
> I'd like to pass hashes to Perl subroutine to process things
> then return the results back to template.
>
>
>
>
>
> I tried something like this but it didn't work:
>
>
> [% result(a => "1", b => "2") %]
>
>
>
>
>
> Perl TT config:
>
>
> my $config = {
>
>
> VARIABLES
> => {
>
>
> result
> => \&calculate,
>
>
> },
>
>
> };
>
>
>
>
>
> Perl subroutine:
>
>
> sub calculate {
>
> my (@args) = @_;
>
> return $args{a} + $args{b} if @args;
>
>
> }
>
>
>
>
>
> It's working if I tried this but I'm not
> preferred:
>
>
> [% result("a", "1", "b",
> "2") %]
>
>
>
>
>
> Thanks,
>
>
> Chakkit
>
>
>
>
>
>
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates