Skip to content

Instantly share code, notes, and snippets.

@niklasl
Created July 2, 2011 18:04
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 niklasl/1061469 to your computer and use it in GitHub Desktop.
Save niklasl/1061469 to your computer and use it in GitHub Desktop.
Some JSON to HTML
fpath = process.argv[2]
file = require('fs').readFileSync fpath, 'utf-8'
data = JSON.parse file
window = require('jsdom').jsdom(null, null).createWindow()
$ = require('jquery').create window
for key, items of data
dl = $("<dl id='#{key}'></dl>").appendTo $('body')
for num, value of items
dl.append "<dt>#{num}</dt><dd>#{value}</dd>"
require('util').print window.document.outerHTML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment