1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-27 06:34:45 +01:00
liquid/expressions/context.go
2017-06-27 15:10:44 -04:00

28 lines
667 B
Go

package expressions
// Context is the expression evaluation context. It maps variables names to values.
type Context interface {
Get(string) interface{}
Set(string, interface{})
}
type context struct {
vars map[string]interface{}
copied bool
}
// NewContext makes a new expression evaluation context.
func NewContext(vars map[string]interface{}) Context {
return &context{vars, false}
}
// Get looks up a variable value in the expression context.
func (c *context) Get(name string) interface{} {
return c.vars[name]
}
// Set sets a variable value in the expression context.
func (c *context) Set(name string, value interface{}) {
c.vars[name] = value
}