[LRUG] Rails Code Help

Anthony Green Anthony.Green at bbc.co.uk
Fri Feb 29 08:45:27 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

NB I tried sending this from my home account but its failed to make it.




http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
					



More information about the Chat mailing list