Documentation
¶
Overview ¶
Package filter applies filters (`count`, `jsonpath`, `toInt`, …) to the value of a query.
Index ¶
- func Apply(items []*syntax.FilterItem, v value.Value, env *template.Env, inAssert bool) (value.Value, error)
- func ApplyOptions(items []*syntax.FilterItem, v value.Value, env *template.Env, opts Options) (value.Value, error)
- func Eval(f *syntax.Filter, v value.Value, env *template.Env, inAssert bool) (value.Value, error)
- func EvalJSONPath(doc value.Value, expr *syntax.Template, env *template.Env, coerce bool) (value.Value, error)
- func EvalOptions(f *syntax.Filter, v value.Value, env *template.Env, opts Options) (value.Value, error)
- func EvalXPath(doc *xpath.Document, expr *syntax.Template, env *template.Env) (value.Value, error)
- func FirstGroup(re *regexp.Regexp, s string) (string, bool)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(items []*syntax.FilterItem, v value.Value, env *template.Env, inAssert bool) (value.Value, error)
Apply applies filters in order to v. A nil result means the last filter produced no value; a filter that receives no value fails. inAssert marks errors raised while evaluating an assert.
func ApplyOptions ¶ added in v1.5.0
func ApplyOptions(items []*syntax.FilterItem, v value.Value, env *template.Env, opts Options) (value.Value, error)
ApplyOptions is Apply with every option.
func EvalJSONPath ¶
func EvalJSONPath(doc value.Value, expr *syntax.Template, env *template.Env, coerce bool) (value.Value, error)
EvalJSONPath evaluates a JSONPath template on a document. With coerce, no match gives nil, one match its value and several matches a list; without, the result is always the list of matches.
func EvalOptions ¶ added in v1.5.0
func EvalOptions(f *syntax.Filter, v value.Value, env *template.Env, opts Options) (value.Value, error)
EvalOptions is Eval with every option.
Types ¶
type Options ¶ added in v1.5.0
type Options struct {
// InAssert marks errors raised while evaluating an assert.
InAssert bool
// NoJSONPathCoercion keeps the result of a jsonpath filter a list of
// matches, even for no match or a single one.
NoJSONPathCoercion bool
}
Options change how filters evaluate.
Click to show internal directories.
Click to hide internal directories.