On Mon, 5 Dec 2005, Gareth Kirwan wrote:
Has anyone had any success using a join in a mason line like this:

% join ",\n", map {
<% $_ %>
%    } qw/foo bar fish/;

The map on it's own works fine, obviously, but the join is
considered contextless.

What does it get compiled to?
I know what you mean, though, it's annoying to do

% @arr = qw/foo bar fish/;
% for (0 .. $#arr) {   $m->out(",\n") if $_ != 0;
      <% $arr[$_] %>
% }

or

% @arr = qw/foo bar fish/;
<% shift @arr %>
% for (@arr) {
, <% $_ %>
% }

in order to separate HTML text by something.
You could maybe wrap it all in <% %>:

<% join ",\n", map { "
 $_
" } qw/foo bar fish/ %>

though that's also ugly. We do something like that for
the breadcrumbs on our site:

<td class="brdcmb">
<% join(' > ', map(qq{<a href="$_->{'URI'}">$_->{'text'}</a>}, @breadcrumbs)) %>
<br /><img src="<% $SHIM %>" width="1" height="5" alt="" border="0" />
</td>

Most HTML people would freak out if they looked at that, though.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to