eval

fun eval(raw: Any, context: Context, fallback: () -> Expression = { blockMarkdown(raw, context).asNodeValue() }): OutputValue<*>

Evaluates an expression from a raw string input.

Return

the result of the evaluation of the expression (in the previous example: ComposedExpression(DynamicValue("2 + 2 is "), FunctionCall(sum, 2, 2))), or the result of the fallback function if the expression is invalid

Parameters

raw

string input that may contain both static values and function calls (e.g. "2 + 2 is .sum {2} {2}")

context

context to retrieve the pipeline from

fallback

value to return if the expression is invalid or an error occurs during the evaluation. A common example of an invalid expression evaluation is when a NodeValue is present in a ComposedExpression, hence the expected output is a pure Markdown output node. The fallback function defaults to returning a block-Markdown content node.