module
routes
File-based routes: the table weft-build generates from app/.
Each Route is a page at a URL pattern (/blog/:slug/, /docs/*path/). root is the component that renders whichever page the path names, inside its layouts. Its template comes from the build: routes are numbered depth-first through the layout tree, so every layout covers a contiguous range of route numbers and the template picks branches with if route <= n. Layouts shared by two routes stay mounted when the path moves between them.
Structs
Enums
- Mode
How an app's pages reach the browser (
[app] modeinweft.toml).
Functions
base
pub fn base() -> &'static strThe base path of the app being rendered (/blog/), set by root; / otherwise. Templates' relative request URLs resolve against it.
current_path
pub fn current_path() -> StringThe path root is rendering (/blog/hello/), for code that needs it outside a page's parameters; / before any.
resolve
pub fn resolve(routes: &[Route], path: &str) -> Option<(usize, Params)>The route path names and its parameters. When several match, the most specific wins: /blog/new/ over /blog/:slug/ over /blog/*rest/.
root
pub fn root(routes: Routes, path: Signal<String>) -> ComponentThe component that renders the page at path, inside its layouts. Its scope has route (the route's number, or -1 when none matches), params and path, which the generated template passes to every layout and page.
set_navigator
pub fn set_navigator(f: impl Fn(&str) + 'static)Set what navigate("/path") in a template does: weft::web::start_app shows the page without loading it. Without one, it does nothing.
template_params
pub fn template_params(template: &Template, names: &[&str]) -> Vec<Params>The parameter sets a page's static params declares, for a route whose parameters are names. Each item of its list is a record of the parameters, or, for a route with one parameter, its value (a list of segments for a catch-all).
template_title
pub fn template_title(template: &Template, params: &Params) -> Option<String>A page's meta title worked out for params, reading its declarations as template_params does: title: "{post.title} — Margins". None when it has no title or the title can't be worked out ahead of a render.