Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I've been using the Template module for quite a while now and have had no problems, I can figure out most things on my own. In fact, this is the first time I'm unable to solve this by myself and it's frustrating me :). I've got the following array (with real data, not typed numbers) and am passing it to Template as shown.:
my $options = [ qw(one two three) ]; $TMPL->process('somewhere.tmpl', { myopts => $options } );
Okay, so that part is trivial. Now, within the template (somewhere.tmpl in the example), I am using a [% PROCESS another.tmpl %]. Now, this other template is expecting an array of hashes in a variable called 'options'. Each one of the options needs to be passed along in the 'value' key of the hash. Since that probably doesn't make much sense in words, here's some perl pseudo-code for what I need to accomplish in TT syntax:
[% PROCESS "another.tmpl" options = [ map { {value => $_} } myopts ] %]
I've checked the TT docs and I can't find a map() within TT. There is a grep virtual method, but no map. How do I go about passing this barrier? It's proving to be more difficult to me than you'd think! I thank thee brother or sister ahead of time for your wonderful wisdom.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Juggling structures with Template Toolkit
by merlyn (Sage) on Apr 02, 2004 at 21:48 UTC | |
by Anonymous Monk on Apr 02, 2004 at 21:58 UTC | |
by perrin (Chancellor) on Apr 02, 2004 at 22:08 UTC | |
by Anonymous Monk on Apr 02, 2004 at 22:08 UTC | |
by jeffa (Bishop) on Apr 03, 2004 at 20:14 UTC | |
|
Re: Juggling structures with Template Toolkit
by perrin (Chancellor) on Apr 02, 2004 at 21:55 UTC | |
by Anonymous Monk on Apr 02, 2004 at 22:02 UTC |