Thanks, Robin and Clinton.

I didn't try Clinton's recommendation to quote the key of the hash I was 
passing in, because I'd already figured out that I had to pass parameters in to 
my subs using references.  Which, BTW, I generally do, however, I've been 
trying to adhere to the standard practices of the development group in which I 
work.  Now we'll do both from now on.

Thanks, guys.

-Eric.

-----Original Message-----
From: Robin Smidsrød [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 03, 2007 11:31 AM
To: [email protected]
Cc: Berg, Eric
Subject: Re: [Templates] Calling class methods with parameters from templates

Berg, Eric wrote:
> I'm traversing a hierarchy, and need to get one object from another from
> within a template.   I'm having difficulty passing in parameters to my
> instance method from the template.  Here's some code to explain:
>
> I have an array of "suites" from which I get an individual "suite":
>
>   [% FOREACH suite = suites %]
>
> I need to get a "suite_runner" from the suite which I do in regular 
> perl code like so:
>
> my $runner = $suite->get_runner(ENVIRONMENT => 'PROD');
>
> I've tried to:
>
> [% runner = suite.get_runner(ENVIRONMENT => env) %]
>
> But I'm getting errors like:
>
> [Tue Jul  3 11:01:23 2007] regression_builder.cgi: Reference found 
> where even-sized list expected at .../lib/site_perl//TestSuite.pm line 68.
>   
If you allow you get_runner() method take arguments like this (hashref instead 
of hash-as-array-arguments)

$suite->get_runner({ENVIRONMENT => 'PROD' });

You should probably be out of problems.

-- Robin

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - -

This message is intended only for the personal and confidential use of the 
designated recipient(s) named above.  If you are not the intended recipient of 
this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited.  This 
communication is for information purposes only and should not be regarded as an 
offer to sell or as a solicitation of an offer to buy any financial product, an 
official confirmation of any transaction, or as an official statement of Lehman 
Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  
Therefore, we do not represent that this information is complete or accurate 
and it should not be relied upon as such.  All information is subject to change 
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this 
communication (including any attachments) is not intended or written to be used 
and cannot be used for the purpose of (i) avoiding U.S. tax related penalties 
or (ii) promoting, marketing or recommending to another party any transaction 
or matter addressed herein.



_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to