Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# MIT license # Let's you create a nested list from a nested array and even pass it a block: # <%= ul(["first", "first", ["second", ["third", "third", "third"], "second", "second", ["third", "third", "third", ["fourth", "fourth", "fourth"]]]]) {|x| link_to x, :controller => "account", :action => "signup" }%> # Don't like hardcoding cycle into this but there you have it def html_list(type, elements, options = {}, &block) items = elements.map do |element| if element.is_a?(Array) element = html_list(type, element, options, &block) else element = block.call(element) if block content_tag("li", element, :class => cycle("even_list", "odd_list")) end end content_tag(type, items, options.merge!(:class => cycle("even_list", "odd_list"))) end def ul(*args, &block) html_list("ul", *args, &block) end def ol(*args, &block) html_list("ol", *args, &block) end
This paste will be private.
From the Design Piracy series on my blog: