Hi,

Over the last year and a half I've been doing more and more things I used to do with Mason with TT instead. Mostly I am very happy with it (or I would use Mason), but of course there are a few things I'm missing.

One of them is an idiom like this:

Foo: <% join "--", map { $_->name } $beer->types %><br />

($beer->types returns a list of objects; I need to call "name" on each and join it with "--")


Or a slightly more complicated variation of the same:


Blah: <% join ", ", map { qq[<a href="/job/] . $_->ID . q[">]. $_->Title . q[</a>] } $company->Jobs %><br />

Very Perlish (oh wait, it is perl! :-) )

With TT I end up with something like the following to do the same:

[% jobs = [];
   FOR j = company.Jobs;
     str = '<a href="/job/' _ j.ID _ '">' _ j.Title;
     jobs.push(str);
   END %]
Blah: [% jobs.join(", ") %]<br />

Did I miss something obvious?


- ask


--
http://www.askbjoernhansen.com/


_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to