Skip to content

Instantly share code, notes, and snippets.

@blazes816
Created July 16, 2012 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blazes816/3123382 to your computer and use it in GitHub Desktop.
Save blazes816/3123382 to your computer and use it in GitHub Desktop.
# in your helpers...
def fancy_display(parent)
"".tap do |content|
parent.each do |child|
content << content_tag(:tr, content_tag(:td, child.to_s), :class => "header-#{child.to_s}")
child.each do |grandchild|
content << content_tag(:tr, content_tag(:td, grandchild.to_s))
end
end
content = content_tag :table, content
end
end
# in your erb
<%= raw fancy_display(my_obj) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment