From: Lionel Thiry Date: 2005-04-22T08:54:31+09:00 Subject: Re: for .. in .. else? Douglas Livingstone a �crit : > In my erb templates, I've got this pattern quite often: > > > > <% for aSong in songList %> > > <% end %> > <% unless songList.empty? %> > > <% end %> >
Songs<%= aSong.name %>no songs!
> > Is there any way to write is more like this: > > > > <% for aSong in songList %> > > <% else %> > > <% end %> >
Songs<%= aSong.name %>no songs!
> <% (songList.empty? ? ["no songs!"] : songList).each do |aSong| %> <% end %>
Songs<%= aSong %>
-- Lionel Thiry Personal website: http://users.skynet.be/lthiry/