Merge branch 'dev'

This commit is contained in:
trans_soup 2023-07-16 15:23:06 +02:00
commit 1da88ebae2

32
README.md Normal file
View file

@ -0,0 +1,32 @@
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:
```javascript
[
"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`.