1
0
mirror of https://github.com/danog/liquid.git synced 2025-01-23 02:21:15 +01:00
liquid/evaluator.go
2017-06-26 08:23:50 -04:00

17 lines
323 B
Go

package main
import "fmt"
type Expression struct {
value func(Context) (interface{}, error)
}
func EvaluateExpr(expr string, ctx Context) (interface{}, error) {
lexer := newLexer([]byte(expr + ";"))
n := yyParse(lexer)
if n != 0 {
return nil, fmt.Errorf("parse error in %s", expr)
}
return lexer.val(ctx), nil
}