---#[model]structTodo {
#[validate(len = 1..=100)]
text: String,
}
staticTODOS: Table<Todo> = Table::saved();
#[action]fnadd(todo: Todo) {
TODOS.add(todo)?;
}
#[action]fnremove(id: u64) {
TODOS.remove(id)?;
}
---
<title>Todos (${TODOS.len()})</title>
<metaname="description"content="A todo list that saves its rows and checks what you add.">
<h1>Todos</h1>
<formaction="?/add"fields />
{#eachTODOS.all() astodo}
<p> ${todo.text}
<buttonaction="?/remove&id=${todo.id}">
Remove
</button>
</p>
{/each}
localhost:3000
Todos (3)
Buy milk
Write the docs
Learn to code
A Page Is One File
Put the model, the form actions and the markup of a page in one file. Wisp compiles the file to Rust, so the compiler checks your template as it checks the rest of your code.
See Wisp Run
Watch the Wisp 1.0 showcase. The video loads from YouTube only after you press play.