module Haml::Helpers

def list_of(enum, &block)

Other tags:
    Yieldparam: item - An element of `enum`

Other tags:
    Yield: - A block which contains Haml code that goes within list items

Parameters:
  • enum (Enumerable) -- The list of objects to iterate over
def list_of(enum, &block)
  to_return = enum.collect 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
    "<li>#{result}</li>"
  end
  to_return.join("\n")
end