Guide
Frontmatter — multi driver
Declare multiple namespaces with their own drivers. Model paths are kv.namespace.key.
Each key in the kv: map is a namespace with its own driver. Model paths are kv.<namespace>.<key> (or kv.<namespace> for http URL resources).
A string value is a shortcut for the http driver with resource: true.
Build a todo desk
Three drivers in one document:
| Namespace | Driver | Why |
|---|---|---|
config | browser (localStorage) | User name + dark/light mode survive reloads |
draft | memory | New-todo form fields die with the tab |
todos | http shortcut | Remote checklist from an API |
frontmatter
---
kv:
config:
driver: browser
mount: user-config
default:
name: Ada
dark: false
draft:
driver: memory
mount: compose
default:
todo: ""
completed: false
todos: https://jsonplaceholder.typicode.com/todos?_limit=5
---
# Todo desk
Hello **{{ kv.config.name }}**.
:input{::value="kv.config.name" placeholder="Your name"}
:input{::checked="kv.config.dark" type="checkbox"} Dark mode
## New todo
::form{::value="kv.draft" method="POST" url="https://jsonplaceholder.typicode.com/todos"}
:input{::value="kv.draft.todo" name="title" placeholder="What needs doing?"}
:input{::checked="kv.draft.completed" name="completed" type="checkbox"} Mark as completed
::button[Add todo]{type="submit"}
::
::
## Todos
:input{::checked="kv.todos.0.completed" type="checkbox"} {{ kv.todos.0.title }}
:input{::checked="kv.todos.1.completed" type="checkbox"} {{ kv.todos.1.title }}
Use the HTTP shortcut long form
Equivalent long form for the http resource:
todos-long-form
todos:
driver: http
mount: todos
base: https://jsonplaceholder.typicode.com/todos?_limit=5
resource: true