Skip to content

Instantly share code, notes, and snippets.

@Paxa
Created August 1, 2009 15:53
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 Paxa/159699 to your computer and use it in GitHub Desktop.
Save Paxa/159699 to your computer and use it in GitHub Desktop.
def file_tree files, sub = nil, &proc
res = "<ul #{'class="subdir"' if sub }>"
files.each do |file, value|
subdir = (value.class == Hash) ? file_tree(value, 1) { |a, b| proc.call a, b } : nil
res += proc.call file, subdir
end
res + '</ul>'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment