1.0.0 • Published 5 years ago
dainty v1.0.0
dainty
render DOM to string server-side
A tiny library that simplifies rendering DOM to string server-side.
Installation
$ npm install dainty
Example
const dainty = require('dainty');
// Element shape is [name, attributes, children]
const elements = [
[
'svg',
{
xmlns: "http://www.w3.org/2000/svg"
},
[
'rect',
{
x: 10,
y: 10,
width: 30,
height: 30,
stroke: 'black'
}
]
]
];
const string = dainty(elements); // returns the elements as a string: '<svg ...>...</svg>'
API
dainty(elements) ⇒ string
Render DOM to string server-side
Kind: global function Returns: string - The elements as a string
Param | Type | Description |
---|---|---|
elements | Array | An array of elements to render |