Compact record format HTML at JavaScript
npm install jstohtmljstohtml
========




Compact record format HTML at JavaScript.
HTML
`
$3
`
npm install jstohtml --save-dev
``js
import jstohtml from 'jstohtml';
console.log(jstohtml({c: 'Hello world!'}));
`Examples
$3
| Input | Output |
| ----------- | ----------- |
|jstohtml('Hello world!');|Hello world!|
|jstohtml({});||
|jstohtml({cl: 'main'});||
|jstohtml({cl: ['main', 'red']});||
|jstohtml({title: 'My title', 'data-a': 123, style: 'font-size: 2em'});||
|jstohtml({t: 'p', cl: ['main', 'red'], c: 'Content'});|Content
|
|jstohtml([]);| |
|jstohtml([{}, {}]);||
|jstohtml([{c: {c: 'Content'}}]);||
|jstohtml([{c: [{c: 'Content1'}, {c: 'Content2'}] }]);||$3
| Input | Output |
| ----------- | ----------- |
|jstohtml({b: 'example'}); // block||
|jstohtml({b: 'example', e: 'elem'}); // block, elem||
|jstohtml({b: 'example', m: {a: true, b: 'val'}}); // block, mod||
|jstohtml({b: 'example', e: 'elem', m: {a: true, b: 'val'}}); // block, elem, mod||$3
`JavaScript
jstohtml([
{
c: 'Menu:'
},
{
t: 'ul', // tag
cl: ['menu', 'menu_theme-normal'], // class attribute
c: [ // content or children
{
t: 'li',
cl: 'menu-option',
title: '1', // attribute
'data-first': 'yes', // data attribute
//...
c: '1'
}, {
t: 'li',
cl: 'menu-option',
title: '2'
c: '2'
}, {
t: 'li',
cl: 'menu-option',
title: '3',
c: '3'
}
]
}
]);
``HTML
Menu:
``