[LRUG] Code Help

Anthony Green email at acgreen.co.uk
Fri Feb 29 06:29:10 PST 2008


Can anyone suggest any improvements to this code


def tree_to_nested_list(object, &block)
 content_tag(:ol) do
  content_tag(:li) do
   html = yield object if block_given?
   html += object.children.map { |child| tree_to_nested_list(child, &block)
}.join('\n')
   end
 end
end


Its intended to traverse an object graph and generate a nested list set
representing the hierarchy
 
Tony






More information about the Chat mailing list