Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EachValue ¶ added in v0.0.2
EachValue converts a plain Go value into a slice of items for iteration by the workflow engine's `each` blocks. Scripting engines should use this helper when implementing Value.Items for values that are already Go-native.
Slices and arrays become a []any of their elements. Maps with string keys become a list of {"key", "value"} pairs ordered by sorted key so iteration is deterministic. Scalars become single-element slices. Unknown types return an error.
func IsTruthyValue ¶ added in v0.0.2
IsTruthyValue returns whether a plain Go value should be treated as truthy in workflow conditions. Scripting engines should use this helper when implementing Value.IsTruthy for values that are already Go-native.
The rules are intentionally pragmatic for workflow authoring:
- bool: itself
- numeric: non-zero is truthy
- string: non-empty and not "false" (case-insensitive)
- slices/maps (any element or key type): non-empty is truthy
- nil: false
- anything else: non-nil is truthy
Types ¶
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is a parsed ${...} template. Templates are the only interpolation syntax in the workflow engine. A template may be:
- Literal — contains no ${...} tokens. Eval returns the raw string.
- Single-expression — the whole trimmed raw string is exactly one ${expr}. Eval returns the typed value produced by the script engine (preserving number, bool, array, map, etc.).
- Interpolated — the raw string mixes literal text with one or more ${expr} tokens. Eval returns a concatenated string, with each expression value stringified via Value.String().
This is "contextual type inference": callers wishing to pass a typed value (number, bool, slice) through a parameter write the whole value as a single ${...} token; callers building a string (URLs, messages, topics) interpolate tokens inside surrounding text and get a string back.
func NewTemplate ¶
NewTemplate parses raw as a ${...} template and compiles every expression it contains against engine. Returns an error if any expression is syntactically malformed (unclosed brace) or fails to compile.
func (*Template) Eval ¶
Eval evaluates the template. For literal templates the raw string is returned as-is. For single-expression templates the script's typed value is returned. For interpolated templates the result is the concatenated string with each expression stringified.
func (*Template) EvalString ¶ added in v0.0.2
EvalString evaluates the template and always returns a string. For single-expression templates this stringifies the typed value; use Eval instead when preserving the underlying type matters.
type Value ¶
type Value interface {
// Value returns the Go value for this value as an any
Value() any
// Items returns the items for this value as an array of any
Items() ([]any, error)
// String returns the string representation of this value
String() string
// IsTruthy returns true if this value is truthy
IsTruthy() bool
}
Value represents the result of a script evaluation.