public string format(VMContext context) { var value = new ExprVM(context).evaluate(this.expr); if (value is StringValue strValue) { return(strValue.value); } if (context.hooks != null) { var result = context.hooks.stringifyValue(value); if (result != null) { return(result); } } throw new Error($"ExpressionNode ({TSOverviewGenerator.preview.expr(this.expr)}) return a non-string result!"); }
public string format(VMContext context) { var items = new ExprVM(context).evaluate(this.itemsExpr); if (!(items is ArrayValue)) { throw new Error($"ForNode items ({TSOverviewGenerator.preview.expr(this.itemsExpr)}) return a non-array result!"); } var result = ""; foreach (var item in (((ArrayValue)items)).items) { if (this.joiner != null && result != "") { result += this.joiner; } context.model.props.set(this.variableName, item); result += this.body.format(context); } /* unset context.model.props.get(this.variableName); */ return(result); }