1.1.0 • Published 5 years ago

object2html v1.1.0

Weekly downloads
4
License
LGPL-3.0
Repository
github
Last release
5 years ago

Object2HTML

logo

Convert the following formated object to a HTMLElement

{_:'tagname',//defaults to 'div' if not defined
	attr||a:{},//attributes
	prop||p:{},//properties
	event||e:{},//events
	child||c:[/*other objects*/]//childNodes
}

Usage

npm i object2html

Then import or require it in your code depends on your environment:

import {Object2HTML} from 'path/to/object2html';
//or
const {Object2HTML} = require('object2html');

Object2HTML(object,func);

  • object : The object to be converted to dom element, or a string(will be converted to a text node).
  • func : (optional) A function to be called after every element created, the parameter is the element.

Return the dom element.