[Templates] map-like vmethod?

[prev] [thread] [next] [Date index for 2004/09/14]

From: Paul Makepeace
Subject: [Templates] map-like vmethod?
Date: 12:05 on 14 Sep 2004
I have data like,

  [ { name => "foo", type => "bar" },
    { name => "baz", type => "bar" },
    { name => "arf", type => "bat" },
    # ...
  ]

Is there a way/vmethod to pull out all the names in Template `a la,
  join " ", map $_->{name}, @data?

I usually do something like,
  [% FOREACH i = data; i.name; " "; END %] (which has a trailing space
UNLESS loop.last)

I find myself doing this quite a bit [just me?] and it rarely gets more
complex than this; i.e. no need for some generic map function. More of a
vertical hash slice.

Paul

        -- 
        Paul Makepeace .............................. http://paulm.com/inchoate/

"If ice is hot, then hold on tightly!"
   -- http://paulm.com/toys/surrealism/

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] map-like vmethod?
Paul Makepeace 12:05 on 14 Sep 2004

Re: [Templates] map-like vmethod?
Tony Bowden 20:06 on 14 Sep 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52