import { build } from 'deleight/dom'
// create a template 1:
const items = it => it.map(num => ({li: num})); // you can abbreviate simple elements
// create a template 2:
const footer = year => `<footer>© ${year}</footer>`;
// use templates:
const ul = build({
main: [
{}, // attributes
[ // children
// object form:
{ ul: [{ class: 'list1' }, items([1,2,3,4,5,6,7,8,9])] },
// text form:
footer(1991)
]
]
});
// reuse a template:
const ol = build({
ol: [
{ class: 'list2' }, // attributes
items([1,2,3,4,5,6,7,8,9,10]), // children
ol => ol.onclick = console.log.bind(console), // component
// further components separated by comma...
]
});
Build an element from the IElement. Use in the browser.