struct
Scope
pub struct Scope(/* private */);An immutable, cheaply clonable set of bindings with an optional parent.
Methods
signal
pub fn signal<T: Clone + Into<Value> + 'static>(self, name: &str, signal: &Signal<T>) -> ScopeBind a signal; templates re-render when it changes.
memo
pub fn memo<T: Clone + PartialEq + Into<Value> + 'static>(self, name: &str, memo: &Memo<T>) -> ScopeBind a memo.
computed
pub fn computed<V: Into<Value>>(self, name: &str, f: impl Fn() -> V + 'static) -> ScopeBind a value computed on each read.
handler
pub fn handler(self, name: &str, f: impl Fn(&Event) + 'static) -> ScopeBind an event handler.
function
pub fn function(self, name: &str, f: impl Fn(&[Value]) -> Value + 'static) -> ScopeBind a function templates can call (slugify(title), or title |> slugify). Keep it pure: the same arguments, the same result, and no changes to state. It takes priority over a standard function of the same name.
function_for
pub fn function_for(&self, name: &str) -> Option<ScopeFunction>The function bound to name, if any.
child
pub fn child(&self, name: &str, value: Value) -> ScopeA child scope with one extra binding (used for loop variables).
resolve
pub fn resolve(&self, path: &Path) -> Option<Value>Resolve a path to a value (handlers are not values).
unresolved
pub fn unresolved(&self, path: &Path) -> StringWhy path doesn't resolve, for an error: the name isn't bound, or a record on the way has no such field (listing the fields it has, so event.deltaX points at event.delta-x), or isn't a record.
handler_for
pub fn handler_for(&self, path: &Path) -> Option<Handler>Resolve a single-segment path to a handler.