dom-tagged-template

tagged template function for DOM building


Keywords
DOM, jsx, tagged, template, create, element
License
ISC
Install
npm install dom-tagged-template@1.2.1

Documentation

DOM helper to create elements/fragments similarly to jsx

Build Status

const $ = require('dom-tagged-template');

const ul = $`<ul onClick=${e => {e.target.style.color=`hsl(${Math.floor(360*Math.random())},100%,50%)`}}>
	${[1,2,3].map(x => $`<li>${x}</li>`)}
</ul>`.firstChild;

const div = $`<div>
	<u onClick=${console.log}>Hello ${'!'.repeat(4)}</u>
	${ul}
</div>`.firstChild;

const fragment = $`
	<i>hello</i>
	@
	<br/>
	<marquee>world</marquee>
`;

live example