A simple library for composable DOM elements using tagged template strings.
If you're looking for a higher level front end framework, try yo-yo. Or even higher than that, try choo.
For a more in depth tutorial on getting started, please check out the wiki.
Please use yo-yoify which will transform any Function.caller into plain strings until an alternative solution to identify element creators is implemented.
yo-yoify can resolve the error like below:
TypeError: Function.caller used to retrieve strict caller
or
TypeError: access to strict mode caller function is censored
Create an element:
// list.js var bel = module { return bel`<ul> </ul>`}Then pass data to it and add to the DOM:
// app.js var createList = var list = documentbody// list.js var bel = // The DOM is built by the data passed in module { { return bel`<ul> </ul>` } { return bel`<button onclick=></button>` } var element = return element}// app.js var bel = var morphdom = var list = module { { // When a bear is selected, rerender with the newly selected item // This will use DOM diffing to render, sending the data back down again } { return bel`<div className="app"> <h1>Selected: </h1> </div>` } // On first render, we haven't selected anything var element = return element}Use the onload and onunload properties to call a function when the element
is inserted and removed from the DOM respectively.
var bel = var modal = bel`<div onload= onunload=>hello!</div>` documentbodydocumentbodyhyperx is built into bel but there may be times when you wish to use your
own version or implementation of hyperx. Or if you prefer to create elements
using bel without using tagged template literals:
var createElement = createElementvar hyperx = var bel = var element = bel`<div class="heading">Hello!</div>` // ... var sameElement = bel sets attributes with element.setAttribute() and element.setAttributeNS(), and creates text nodes with document.createTextNode(). These approaches mitigate some Cross-Site Scripting (XSS) attacks. You should still code carefully every time you put content from users in the DOM.
(c) 2016 Kyle Robinson Young. MIT License