def list_of(enum, opts={}, &block)
      opts_attributes = opts.map { |k, v| " #{k}='#{v}'" }.join
      enum.map do |i|
        result = capture_haml(i, &block)

        if result.count("\n") > 1
          result.gsub!("\n", "\n  ")
          result = "\n  #{result.strip}\n"
        else
          result.strip!
        end

        %Q!<li#{opts_attributes}>#{result}</li>!
      end.join("\n")
    end
def list_of(enum, opts={}, &block)
      opts_attributes = opts.map { |k, v| " #{k}='#{v}'" }.join
      enum.map do |i|
        result = capture_haml(i, &block)

        if result.count("\n") > 1
          result.gsub!("\n", "\n  ")
          result = "\n  #{result.strip}\n"
        else
          result.strip!
        end

        %Q!<li#{opts_attributes}>#{result}</li>!
      end.join("\n")
    end
Takes an `Enumerable` object and a block
 and iterates over the enum,
 yielding each element to a Haml block
 and putting the result into `<li>` elements.
 This creates a list of the results of the block.
 For example:

     = list_of([['hello'], ['yall']]) do |i|
       = i[0]

 Produces:

     <li>hello</li>
     <li>yall</li>

 And:

     = list_of({:title => 'All the stuff', :description => 'A book about all the stuff.'}) do |key, val|
       %h3= key.humanize
       %p= val

 Produces:

     <li>
       <h3>Title</h3>
       <p>All the stuff</p>
     </li>
     <li>
       <h3>Description</h3>
       <p>A book about all the stuff.</p>
     </li>

 While:

     = list_of(["Home", "About", "Contact", "FAQ"], {class: "nav", role: "nav"}) do |item|
       %a{ href="#" }= item

 Produces:

     <li class='nav' role='nav'>
       <a href='#'>Home</a>
     </li>
     <li class='nav' role='nav'>
       <a href='#'>About</a>
     </li>
     <li class='nav' role='nav'>
       <a href='#'>Contact</a>
     </li>
     <li class='nav' role='nav'>
       <a href='#'>FAQ</a>
     </li>

  `[[class", "nav"], [role", "nav"]]` could have been used instead of `{class: "nav", role: "nav"}` (or any enumerable collection where each pair of items responds to #to_s)

 @param enum [Enumerable] The list of objects to iterate over
 @param [Enumerable<#to_s,#to_s>] opts Each key/value pair will become an attribute pair for each list item element.
 @yield [item] A block which contains Haml code that goes within list items
 @yieldparam item An element of `enum`