eqlang

package
v0.0.0-...-5a4b8d9 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEndRequired is returned if eql script doesn't end by `%>`.
	ErrEndRequired = errors.New("eql script requires `%>` to end")

	// ErrEndOfString is returned if string doesn't end.
	ErrEndOfString = errors.New("string doesn't end")
)
View Source
var Exports = map[string]interface{}{
	"new":   New,
	"parse": Parse,
	"subst": Subst,

	"input":     Input,
	"inputFile": InputFile,

	"New":   New,
	"Parse": Parse,
	"Subst": Subst,

	"Input":     Input,
	"InputFile": InputFile,

	"ErrEndRequired": ErrEndRequired,
	"ErrEndOfString": ErrEndOfString,
}

Exports is the export table of this module.

Functions

func Input

func Input(input string) (ret map[string]interface{}, err error)

Input decodes a json string.

func InputFile

func InputFile(input string) (ret map[string]interface{}, err error)

InputFile decodes a json file.

func Parse

func Parse(source string) (code []byte, err error)

Parse parses eql source into qlang code.

func Subst

func Subst(text string, lang interface{}) string

Subst substs variables in text.

Types

type Type

type Type struct {
	Impl qlang
}

A Type is a eql script engine.

func New

func New(ql qlang) Type

New creates a new eql script engine.

func (Type) Execute

func (p Type) Execute(source string, fname string, output string) (err error)

Execute executes a eql template string.

func (Type) ExecuteDir

func (p Type) ExecuteDir(global map[string]interface{}, source, output string) (err error)

ExecuteDir executes a eql template directory.

func (Type) ExecuteFile

func (p Type) ExecuteFile(source, output string) (err error)

ExecuteFile executes a eql template file.

func (Type) Imports

func (p Type) Imports() string

Imports returns import table.

func (Type) Subst

func (p Type) Subst(text string) string

Subst substs variables in text.

func (Type) Var

func (p Type) Var(name string, defval interface{}) interface{}

Var returns a variable value or defval if not found.

type Variables

type Variables interface {
	GetVar(name string) (v interface{}, ok bool)
}

Variables represent how to get value of a variable.

Jump to

Keyboard shortcuts

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