javascript utility for creating DOM trees from arrays.
assets/styles | ||
js | ||
favicon.ico | ||
index.html | ||
README.md |
small utility for creating DOM trees from javascript arrays.
to use, clone/submodule/subtree/whatever the main
branch, and import json_as_html
from export.mjs
.
to see a demo, or contribute, clone the dev
branch.
here's the demo array being used at the time of writing this:
[
"div",
[
["id", "wrapper"],
["class", "demo_div"],
],
[
["h1", [], "header :)"],
["p", [], "paragraph! meow"],
["p", [], "another paragraph!! this is so cool"],
state => ["button", [
["onclick", _ => {
state.set("clicked", true);
render();
}]
], "it can even do buttons!"],
state => ["p", [], state.get("clicked") ? "clicked" : "not clicked"],
],
]
it assumes a function render
which replaces the contents of the <body>
with the result of calling json_as_html
with this array as argument. it also assumes a Map
called state
.