1.0.0 • Published 8 years ago

build-element v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

build-element Build Status

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