<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: array code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 08 Aug 2008 19:37:07 GMT</pubDate>
    <description>DZone Snippets: array code</description>
    <item>
      <title>Array to HTL list helper</title>
      <link>http://snippets.dzone.com/posts/show/4791</link>
      <description>Makes a HTML list out of any array. The objects in the array is yielded to the block. Usage:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;%= list(@posts) { |post| link_to post.title, posts_url(post) } %&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And the actual helper (put it in application_helper.rb):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def list(stuff, &amp;block)&lt;br /&gt;  content_tag(:ul, stuff.map { |thingie| content_tag(:li, yield(thingie)) })&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 17 Nov 2007 05:37:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4791</guid>
      <author>leethal (August Lilleaas)</author>
    </item>
  </channel>
</rss>
