[Templates] Calling class methods with parameters from templates
Randal L. Schwartz
merlyn@stonehenge.com
Tue, 03 Jul 2007 08:45:24 -0700
>>>>> "Berg," == Berg, Eric <eric.berg@lehman.com> writes:
Berg,> I'm traversing a hierarchy, and need to get one object from another from
Berg,> within a template. I'm having difficulty passing in parameters to my
Berg,> instance method from the template. Here's some code to explain:
Berg,> I have an array of "suites" from which I get an individual "suite":
Berg,> [% FOREACH suite = suites %]
Berg,> I need to get a "suite_runner" from the suite which I do in regular perl
Berg,> code like so:
Berg,> my $runner = $suite->get_runner(ENVIRONMENT => 'PROD');
Berg,> I've tried to:
Berg,> [% runner = suite.get_runner(ENVIRONMENT => env) %]
That's probably turning into the equivalent of:
$suite->get_runner({ ENVIRONMENT => env });
You'll need to call
[% suite.get_runner('ENVIRONMENT', env) %]
instead.
Just guessing, but I think I got bit by that one once.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!