Skip to content

Instantly share code, notes, and snippets.

@adrianpike
Created August 26, 2009 05:10
Show Gist options
  • Save adrianpike/175336 to your computer and use it in GitHub Desktop.
Save adrianpike/175336 to your computer and use it in GitHub Desktop.
# delicious helper
def dlify_hash(hash)
'<dl>'+"\n"+hash.collect{|k,v|
"\t<dd>#{k}</dd><dt>#{v}</dt>"
}.join("\n")+"\n"+'</dl>'
end
# Or, if you're a sick bastard like me and don't care if you've got layout logic monkeypatched into Ruby Core:
class Hash
def to_dl
'<dl>'+"\n"+self.collect{|k,v|
"\t<dd>#{k}</dd><dt>#{v}</dt>"
}.join("\n")+"\n"+'</dl>'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment