@itsfuad/fragmentbuilder
v1.0.2
Published
Builds a document fragment from a javascript object representing HTML.
Downloads
1
Maintainers
Readme
Javascript object to HTML fragment
Json to HTML is a function that converts a JSON object to HTML document fragment. This fragment then can be directly used inside innerHTML.
example
const obj = {
tag: 'div',
text: 'Hello, World!',
attr: {
class: 'container',
id: 'main'
},
childs: [
{
tag: 'h1',
text: 'Hello, World!'
},
]
}
const fragment = fragmentBuilder(obj);