build-element
v1.0.0
Published
Create html elements
Downloads
10
Maintainers
Readme
build-element
Create html elements
Install
$ npm install --save build-element
Usage
const buildElement = require('build-element');
buildElement('div', 'children', { attributes: { class: 'test' }, style: { color: 'blue' } });
//=> '<div class="test" style="color: blue>children</div>'
buildElement('img', { attributes: { src: 'https://source.unsplash.com/random' } });
//=> '<img src="https://source.unsplash.com/random" />'
API
buildElement(element, [children, options])
element
Type: string
The type of element eg. div
, p
, img
, ...
children
Type: string
, array
The element's children.
options
Type: `object``
attributes
Type: object
Attributes for the element eg. class
, src
, ...
style
Type: object
Inline styles
License
MIT © Tobias Herber