Skip to content

module

eval

Evaluating template expressions against a scope.

Expressions are pure: they read the scope and return a value. Reading a signal through the scope subscribes the render, as a plain reference does, so computed values in templates stay reactive. The standard functions are here; their signatures, which the parser checks calls against, are in weft_dsl::stdlib.

Functions

eval

pub fn eval(e: &Expr, scope: &Scope) -> Result<Value, RenderError>

e's value in scope.

format_number

pub fn format_number(n: f64, decimals: Option<usize>) -> String

1234.5 with thousands separators and decimals places (as many as it has, up to 2, when not given).

text

pub fn text(t: &TextTemplate, scope: &Scope) -> Result<String, RenderError>

A string template's text, interpolations evaluated.