bepis
🐕Dynamic HTML + CSS in JavaScript.
npm i bepis
Examples
Simple keyed list, play with it here:
First, import:
;
Then set up some data:
const myItems = name: "Screw" description: "Part" key: "a3" name: "Moxie" description: "Intangible" key: "x5" name: "Sand" description: "Material" key: "p4" ;const newName = "Mojo";
Make some views:
const KeyedItem = w` li p, :text . a :text ..`; const SingletonList = w` ul :map `;
Render the data and mount the view to the document
documentbody;
Make a change and see it
const myChangedItems = ;myChangedItems1name = newName; ;
:text, :map and :comp directives.
- Use
:text
to insert text, and:map
to insert lists, as in the above example. - Use
:comp
to insert components:w`main,h1 .:comp ..`
Basics
- Use template literals tagged with
w
. This creates a 'bepis' - Use ',' operator to save an insertion point
- Use '.' operator to load an insertion point
<tag name> ${attributes} ${styles}
is the format.- Whitespace is ignored.
Up next
- minimal diffing with updator functions.
Related Projects
I don't know. I didn't search any "prior art." Let me know how I reinvented this beautiful wheel by opening a PR request.