in reply to Juggling structures with Template Toolkit

Well, that's bordering on a little too much processing in TT code. But, you can brute force it:
[% # untested and I may get it wrong... sorry newdata = []; FOR item = myopts; newdata.push({ 'value' => item }); END; PROCESS another.tmpl options => newdata; %]

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: Juggling structures with Template Toolkit
by Anonymous Monk on Apr 02, 2004 at 21:58 UTC

    Okay, that makes sense. Thank you.

    that's bordering on a little too much processing in TT code

    How would you go about doing that processing within the script then? I did try something along the lines of the following snippet and it failed horribly. Perhaps I'm just a little off?

    $TMPL->process('something.tmpl', { myopts => [ map { {value => $_} } qw(one two three) ] } ); __END__ [% PROCESS "another.tmpl" options => myopts %]
      That works perfectly for me, except that it looks like you should have assigned that array to "options" instead of "myopts" or maybe both.

      update: I will now admit that I am officially dumbed out for the day. The script method with the map works fine. I don't know what happened earlier. Perhaps I forgot to double up the curly braces around the map. Thanks to merlyn for showing a TT way of doing it anyhow :)

        I asked a similar question on the TT mailing list back in December of 2003. extremely responded "... maybe you should just fix it in Perl rather than trying get TT to be a full language with all the amenities." Indeed, TT is candy store and we are kids. :)

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)