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.


In reply to Juggling structures with Template Toolkit by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.