Gelerator
Generate Element in a simple, HTML-in-JS way.
const g = require('gelerator')
const H1 = g('bold', 'h1')('h1 with class: blod')
const H2 = g({ style: 'background: #ccc; color: #444' }, 'h2')('h2 with style')
const P = g({}, 'p')
const content = g({ id: 'content' })(
H1,
H2,
P('Lorem ipsum dolor sit amet'),
P('Consectetur adipisicing elit. Facilis, aliquid!')
)
$('.target').appendChild(content)
Installation
- npm
- yarn
$ npm install gelerator
-
g('btn')('click me') -
g('btn', 'botton')('content') -
g({ id: 'main', style: 'color: #888' })('ctt') -
g('demo-jpg', 'img')('./demo.jpg') -
g(css`color: rebeccapurple`)('with css-in-js')
Javascript
-
<div class="btn">click me</div> -
<botton class="btn">content</botton> -
<div id="main" style="color: #888">ctt</div> -
<img class="demo-jpg" src="./demo.jpg"> -
<div class="hAsH3dC1as5">with css-in-js</div>
Elements
Generate html in js, no editor window switching.
Star