dominate

DOMinate for node.js

npm install dominate
13 downloads in the last month

DOMinate

Generate html from a simple array based JavaScript representation

Build Status Dependency Status NPM version

Installation

$ npm install dominate

Example

var DOMinate = require('dominate');
DOMinate(
    ['div',
      ['h1#logo', 'Static Example', {style:'color:blue'}],
      ['p','some example text'],
      ['ul', {id:'list', class:'bullets'},
        ['li', 'item1'],
        ['li.active', 'item2'],
        ['li',
          ['a', 'item3', {href: '#'}]
        ]
      ]
    ]
  );

On the server side this returns the string:

<div><h1 id="logo" style="color:blue">Static Example</h1><p>some example text</p><ul id="list" class="bullets"><li>item1</li><li class="active">item2</li><li><a href="#">item3</a></li></ul></div>

On the client side it returns the DOM element

<div>
  <h1 id="logo" style="color:blue">Static Example</h1>
  <p>some example text</p>
  <ul id="list" class="bullets">
    <li>item1</li>
    <li class="active">item2</li>
    <li><a href="#">item3</a></li>
  </ul>
</div>

License

MIT

npm loves you