Documentation ¶
Overview ¶
Package expression parses and evaluates the expression language.
This is the language that is used inside Liquid object and tags; e.g. "a.b[c]" in {{ a.b[c] }}, and "pages = site.pages | reverse" in {% assign pages = site.pages | reverse %}.
Index ¶
Constants ¶
const AND = 57358
const ASSIGN = 57350
const CONTAINS = 57360
const EQ = 57352
const FOR = 57356
const GE = 57354
const IDENTIFIER = 57347
const IN = 57357
const KEYWORD = 57348
const LE = 57355
const LITERAL = 57346
const LOOP = 57351
const NEQ = 57353
const OR = 57359
const PROPERTY = 57349
Variables ¶
This section is empty.
Functions ¶
func EvaluateString ¶
EvaluateString is a wrapper for Parse and Evaluate.
Types ¶
type Closure ¶
type Closure interface { // Bind creates a new closure with a new binding. Bind(name string, value interface{}) Closure Evaluate() (interface{}, error) }
A Closure is an expression within a lexical environment. A closure may refer to variables that are not defined in the environment. (Therefore it's not a technically a closure.)
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds configuration information for expression interpretation.
type Context ¶
type Context interface { ApplyFilter(string, valueFn, []valueFn) interface{} // Clone returns a copy with a new variable binding map // (so that copy.Set does effect the source context.) Clone() Context Get(string) interface{} Set(string, interface{}) }
Context is the expression evaluation context. It maps variables names to values.
func NewContext ¶
NewContext makes a new expression evaluation context.
type Expression ¶
type Expression interface { // Evaluate evaluates an expression in a context. Evaluate(ctx Context) (interface{}, error) }
An Expression is a compiled expression.
func Constant ¶
func Constant(k interface{}) Expression
Constant creates an expression that returns a constant value.
func Not ¶
func Not(e Expression) Expression
Not creates an expression that returns ! of the wrapped expression.
func Parse ¶
func Parse(source string) (expr Expression, err error)
Parse parses an expression string into an Expression.
type InterpreterError ¶
type InterpreterError string
An InterpreterError is an error during expression interpretation. It is used for errors in the input expression, to distinguish them from implementation errors in the interpreter.
func (InterpreterError) Error ¶
func (e InterpreterError) Error() string
type Loop ¶
type Loop struct { Variable string Expr interface{} // contains filtered or unexported fields }
Loop describes the result of parsing and then evaluating a loop statement.
type ParseError ¶
type ParseError string
ParseError represents a parse error.
func (ParseError) Error ¶
func (e ParseError) Error() string
type UndefinedFilter ¶
type UndefinedFilter string
UndefinedFilter is an error that the named filter is not defined.
func (UndefinedFilter) Error ¶
func (e UndefinedFilter) Error() string