mkdom

Convert HTML into DOM elements in the browser and on the server.

mkdom

mkdom converts plain HTML into DOM elements that can be manipulated in browsers and on the server. It makes writing shared rendering logic fairly easy.

npm install mkdom
var fs = require('fs')
var mkdom = require('mkdom')
var html = fs.readFileSync('./templates/readme.html')
 
var page = mkdom(html)
page.querySelector('h1').textContent = 'mkdom'
page.querySelector('p').textContent = 'mkdom converts pl…'
 
process.stdout.write(page.outerHTML)

You can also take a look at a more real world example, mkdom-todos.

MIT