domb
![Coverage Status](https://coveralls.io/repos/github/aristov/domb/badge.svg?branch=main)
DomB is a DOM Builder.
This is a simple cross-platform DOM generation library.
It is a handy tool for creating templates and testing.
Installation
npm install domb
Usage
ES2015
import { div } from 'domb'
CommonJS
const { div } = require('domb')
Example
DomB can be used both in NodeJS and in the browser:
import { form, label, input, button } from 'domb'
const node = form({
action : 'https://google.com/search',
target : '_blank',
children : [
label([
'Search ',
input({ type : 'search', name : 'q' }),
]),
button('Find'),
],
})
document.body.append(node)
app.get('/form', (req, res) => res.send(node.outerHTML))
The node
variable is a DOM structure with the appropriate markup:
<form action=//google.com/search target=_blank>
<label>
Search
<input type=search name=q>
</label>
<button>Find</button>
</form>
License
The MIT License (MIT)