dominatrix

Push brand new DOM structures into pleasant submission!

Dominatrix

Push brand new DOM structures into pleasant submission!

This library assumes an ES5 environment, but can be easily supported in ES3 platforms by the use of shims. Just include es5-shim :3

var _ = require('dominatrix')
 
function link(a) { return _('a.link', { href: a.url }, a.text) }
 
var items = [
  { url: '/example/a', 'Something' }
, { url: '/example/b', 'More stuff' }
]
 
_('html'
 , _('head'
    , _('title', 'Mistress.')
    , _('meta', { charset: 'utf-8' }))
 , _('body'
    , _('div#content.item-list.simple-list', items.map(link))))

This generates the following HTML structure:

<html>
  <head>
    <title>Mistress.</title>
    <meta charset="utf-8">
  </head>
  <body>
    <div id="content" class="item-list simple-list">
      <a class="link" href="/example/a">Something</a>
      <a class="link" href="/example/b">More stuff</a>
    </div>
  </body>
</html>

Just grab it from NPM:

$ npm install Dominatrix

A quick reference of the API can be built using Calliope:

$ npm install -g calliope
$ calliope build

You can run all tests using Mocha:

$ npm test

MIT/X11. ie.: do whatever you want.