Skip to main content

render

Function render 

Source
pub async fn render(template: &str, scope: &Scope) -> String
Expand description

Renders template, evaluating every <% ... %> expression against scope.

For each tag, the expression text is lexed, parsed and evaluated with swan_core::evaluator::eval. If the result is a promise, it is awaited. The final value is converted to text (see the module documentation) and appended to the output. Text outside tags is copied verbatim.

Evaluation mutates scope, so assignments persist across tags and after the call returns. An unclosed <% ends processing, and the remaining text is appended literally.

§Arguments

  • template - the template source text.
  • scope - the scope used to evaluate all expressions.

§Returns

The fully interpolated string.