script

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertEachValue

func ConvertEachValue(value any) ([]any, error)

ConvertEachValue converts any value to an array of values for use in each blocks This works with both Risor objects and plain Go values for extensibility

func ConvertRisorValueToBool

func ConvertRisorValueToBool(obj object.Object) bool

ConvertRisorValueToBool converts a Risor object to a boolean indicating truthiness

func ConvertRisorValueToGo

func ConvertRisorValueToGo(obj object.Object) any

ConvertRisorValueToGo converts a Risor object to a Go value

func ConvertValueToBool

func ConvertValueToBool(value any) bool

ConvertValueToBool converts any value to a boolean indicating truthiness This works with both Risor objects and plain Go values for extensibility

func DefaultRisorGlobals

func DefaultRisorGlobals() map[string]any

func GetSafeGlobals

func GetSafeGlobals() map[string]bool

GetSafeGlobals returns a map of Risor built-in function names that are safe to use in workflows due to being deterministic with no side effects.

Types

type Compiler

type Compiler interface {
	Compile(ctx context.Context, code string) (Script, error)
}

Compiler is an interface used to compile source code into a Script.

type RisorScript

type RisorScript struct {
	// contains filtered or unexported fields
}

func (*RisorScript) Evaluate

func (s *RisorScript) Evaluate(ctx context.Context, globals map[string]any) (Value, error)

type RisorScriptingEngine

type RisorScriptingEngine struct {
	// contains filtered or unexported fields
}

func NewRisorScriptingEngine

func NewRisorScriptingEngine(globals map[string]any) *RisorScriptingEngine

func (*RisorScriptingEngine) Compile

func (e *RisorScriptingEngine) Compile(ctx context.Context, code string) (Script, error)

type RisorValue

type RisorValue struct {
	// contains filtered or unexported fields
}

func (*RisorValue) IsTruthy

func (value *RisorValue) IsTruthy() bool

func (*RisorValue) Items

func (value *RisorValue) Items() ([]any, error)

func (*RisorValue) String

func (value *RisorValue) String() string

func (*RisorValue) Value

func (value *RisorValue) Value() any

type Script

type Script interface {
	Evaluate(ctx context.Context, globals map[string]any) (Value, error)
}

Script represents a compiled script that can be evaluated.

type Template

type Template struct {
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(engine Compiler, raw string) (*Template, error)

func (*Template) Eval

func (e *Template) Eval(ctx context.Context, globals map[string]any) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL