Tidy up HTML-list creation in views with one-liner neatness.
I use this one in pretty much all of them projects of mine.
def list(stuff)
content_tag(:ul, stuff.map { |thingie| content_tag(:li, yield(thingie)) })
end
Usage:
<%= list(@posts) {|post| link_to(post.title, post_url(post)) } %>
Pretty pretty. Much better than this:
<ul>
<% @posts.each do |post| %>
<li><%= link_to(...) %></li>
<% end %>
</ul>