|
|
|
|
@ -84,6 +84,7 @@ func Funcs() map[string]ast.Function {
|
|
|
|
|
"floor": interpolationFuncFloor(),
|
|
|
|
|
"format": interpolationFuncFormat(),
|
|
|
|
|
"formatlist": interpolationFuncFormatList(),
|
|
|
|
|
"indent": interpolationFuncIndent(),
|
|
|
|
|
"index": interpolationFuncIndex(),
|
|
|
|
|
"join": interpolationFuncJoin(),
|
|
|
|
|
"jsonencode": interpolationFuncJSONEncode(),
|
|
|
|
|
@ -675,6 +676,21 @@ func interpolationFuncFormatList() ast.Function {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// interpolationFuncIndent indents a multi-line string with the
|
|
|
|
|
// specified number of spaces
|
|
|
|
|
func interpolationFuncIndent() ast.Function {
|
|
|
|
|
return ast.Function{
|
|
|
|
|
ArgTypes: []ast.Type{ast.TypeInt, ast.TypeString},
|
|
|
|
|
ReturnType: ast.TypeString,
|
|
|
|
|
Callback: func(args []interface{}) (interface{}, error) {
|
|
|
|
|
spaces := args[0].(int)
|
|
|
|
|
data := args[1].(string)
|
|
|
|
|
pad := strings.Repeat(" ", spaces)
|
|
|
|
|
return strings.Replace(data, "\n", "\n"+pad, -1), nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// interpolationFuncIndex implements the "index" function that allows one to
|
|
|
|
|
// find the index of a specific element in a list
|
|
|
|
|
func interpolationFuncIndex() ast.Function {
|
|
|
|
|
|