|
|
|
|
@ -81,6 +81,7 @@ func Funcs() map[string]ast.Function {
|
|
|
|
|
"jsonencode": interpolationFuncJSONEncode(),
|
|
|
|
|
"length": interpolationFuncLength(),
|
|
|
|
|
"list": interpolationFuncList(),
|
|
|
|
|
"log": interpolationFuncLog(),
|
|
|
|
|
"lower": interpolationFuncLower(),
|
|
|
|
|
"map": interpolationFuncMap(),
|
|
|
|
|
"max": interpolationFuncMax(),
|
|
|
|
|
@ -489,6 +490,17 @@ func interpolationFuncCeil() ast.Function {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// interpolationFuncLog returns the logarithnm.
|
|
|
|
|
func interpolationFuncLog() ast.Function {
|
|
|
|
|
return ast.Function{
|
|
|
|
|
ArgTypes: []ast.Type{ast.TypeFloat, ast.TypeFloat},
|
|
|
|
|
ReturnType: ast.TypeFloat,
|
|
|
|
|
Callback: func(args []interface{}) (interface{}, error) {
|
|
|
|
|
return math.Log(args[0].(float64)) / math.Log(args[1].(float64)), nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// interpolationFuncChomp removes trailing newlines from the given string
|
|
|
|
|
func interpolationFuncChomp() ast.Function {
|
|
|
|
|
newlines := regexp.MustCompile(`(?:\r\n?|\n)*\z`)
|
|
|
|
|
|