Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

August Lilleaas http://august.lilleaas.net

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Array to HTL list helper

Makes a HTML list out of any array. The objects in the array is yielded to the block. Usage:


<%= list(@posts) { |post| link_to post.title, posts_url(post) } %>


And the actual helper (put it in application_helper.rb):

   1  
   2  def list(stuff, &block)
   3    content_tag(:ul, stuff.map { |thingie| content_tag(:li, yield(thingie)) })
   4  end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS