enum
Decl
pub enum Decl {
State { name: String, init: Expr },
Let { name: String, expr: Expr },
Prop { name: String, default: Option<Expr>, kind: Option<PropKind> },
Data { name: String, variants: Vec<String> },
On { name: String, params: Vec<String>, actions: Vec<Action> },
Load { name: String, request: Expr },
Timer { kind: TimerKind, when: Option<Expr>, actions: Vec<Action> },
Fn { name: String, params: Vec<String>, body: Expr },
Use { path: String },
StaticParams { expr: Expr },
Provide { names: Vec<String> },
Window { event: String, listener: Listener },
}A declaration at a template's top level.
Variants
Prop
Prop { name: String, default: Option<Expr>, kind: Option<PropKind> }props (name = default, other): a prop the component takes, and what it is when the caller passes none (null without a default).
Data
Data { name: String, variants: Vec<String> }data Size = small | medium | large: a named set of variants.
Timer
Timer { kind: TimerKind, when: Option<Expr>, actions: Vec<Action> }every 1 when cond = action, …, after …, every frame …
Use
Use { path: String }use "shared.weft": another file's declarations, which crate::parse_file puts in its place.
StaticParams
StaticParams { expr: Expr }static params = expr: the route parameters of the pages built ahead of time.
Window
Window { event: String, listener: Listener }@resize: width <- event.innerWidth or @keydown: press(event.key): a window event and what it does, while the component is on the page.
Methods
name
pub fn name(&self) -> &strThe name it declares ("" for a timer, a window event, a use, static params and provide, which declare none).
references
pub fn references(&self, bound: &mut Vec<String>, out: &mut BTreeSet<String>)Names the declaration reads from outside it (its parameters and event excluded), added to out.