Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Template Toolkit - problem getting data out array - AoHoA

by Your Mother (Archbishop)
on Mar 07, 2014 at 19:51 UTC ( #1077449=note: print w/replies, xml ) Need Help??


in reply to Template Toolkit - problem getting data out array - AoHoA

I think your structure is fine. You just have to think more “perlishly” for your iteration. This should get you on the path to what you want–

use strictures; use Template; my $stuff = [ { 'filenameLarge' => [ 'fIyvYwJWmstR.jpg', 'koeSHYEaekfv.jpg', 'CtDKXyiRXhWz.jpg' ], 'title' => 'February event (Feb 2013)', 'bookid' => 8 } ]; my $tt = Template->new; $tt->process(\*DATA, { fotos => $stuff }) || die $tt->error(), "\n"; __DATA__ [%-FOR e IN fotos %] [%-e.title %] [%-FOR i IN e.filenameLarge %] <img src="/photo/[% e.bookid %]/tn/[% i %]" /> [%-END %] [%-END %]

Yields–

February event (Feb 2013) <img src="/photo/8/tn/fIyvYwJWmstR.jpg" /> <img src="/photo/8/tn/koeSHYEaekfv.jpg" /> <img src="/photo/8/tn/CtDKXyiRXhWz.jpg" />

Replies are listed 'Best First'.
Re^2: Template Toolkit - problem getting data out array - AoHoA
by GertMT (Hermit) on Mar 07, 2014 at 21:17 UTC
    pfff... That is great!!

    After so much time getting this structure in place (that is maybe a post for some other time) I thought to have tried every possible trick to get this working. You found me the solution and that makes my day (weekend even!).

    Thank you,
    Gert

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1077449]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2021-10-21 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?