Documentation
¶
Overview ¶
Package el provides an interface and default implementation of expression language (EL) interpreter for struct tags.
Default implementation is simply based on "text/template".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// Name of the currently processed field.
Name string
// Name of the currently processed field including type.
LongName string
// Current value of the currently processed filed.
Val interface{}
// All other tags of the currently processed field.
Tags map[string]string
// Currently processed struct.
Struct interface{}
// Extra context structure.
Extra interface{}
// Temporary partial result evaluated on the current substruct.
Sub interface{}
}
Context is a context, passed to interpreter. It contains information about currently processed field, struct and extra.
type DefaultInterpreter ¶
type DefaultInterpreter struct {
// Custom functions, available for use in EL expressions.
Funcs use.FuncMap
// Left delimiter for templates.
LeftDelim string
// Right delimiter for templates.
RightDelim string
// Automatically enclose passed expression into delimiters before
// interpretation (if it is not already enclosed). This allows to pass
// simplified expressions. For example, `atoi "42"` instead of
// `{{atoi "42"}}`.
AutoEnclose bool
}
DefaultInterpreter is a default implementation of Interpreter, which is based on "text/template".
type Interpreter ¶
type Interpreter interface {
// Execute parses and executes expression with a given context.
Execute(expression string, ctx *Context) (result interface{}, err error)
}
Interpreter is an interface of EL interpreter.
Click to show internal directories.
Click to hide internal directories.