x0/README.md

36 lines
2.2 KiB
Markdown
Raw Normal View History

2023-12-24 00:32:43 +01:00
# x0
A web framework for *lazy* developers.
## What can it do?
It has some attributes that simplify stuff with js.
## Attributes
### Top level attributes
2023-12-24 20:40:28 +01:00
These attributes only work on the html tag.
| attrib | description | default | module |
| -------------------- | ----------------------------------------------------- | --------------- | ------ |
| `x0-mods` | what modules to include | nothing | x0 |
| `x0-module-root` | where to fetch the modules from | `./x0/modules/` | x0 |
| `x0-init` | init x0? | `true` | x0 |
| `x0-locale-file` | which locale file to use | nothing | locale |
| `x0-locale-watch` | add an onchange listener to update locales | | locale |
| `x0-locale-no-cache` | do **not** use cached locales | | locale |
| `x0-locale-default` | default locale | `en` | locale |
| `x0-locale-prefer` | set a preferred locale; ignore users lang if possible | | locale |
2023-12-24 00:32:43 +01:00
### Element Attributes
Attributes you can use
2023-12-24 20:40:28 +01:00
| module | attrib | description | example |
| --------- | ---------------- | ----------------------------------------------------------- | ------------------------------ |
| http | `x-get` | set the element's contents to the result of the get request | `x-get="./content"` |
| http | `x-get-interval` | use with `x-get` to poll the endpoint (millis) | `x-get-interval=1000` |
2023-12-24 20:41:19 +01:00
| http,copy | `x-inner-text` | instead of using innerHTML use innerText | `x-inner-text` |
2023-12-24 20:40:28 +01:00
| copy | `x-copy-query` | copy contents of element matching query selector | `x-copy-query="#content"` |
| locale | `x-locale-key` | fetch locale key and put it in innerHTML | `x-locale-key="main.greeting"` |