tpl: Add intersect operator to where function

Returns true if a given field value that is a slice / array of strings, integers or floats contains elements in common with the matching value. It follows the same rules as the intersect function.

Closes #1945
This commit is contained in:
Christopher Mancini 2016-04-11 16:58:27 -04:00 committed by Bjørn Erik Pedersen
parent 26fe1ca2f8
commit 7d086adbd7

View File

@ -79,7 +79,6 @@ e.g. Pass into "foo.html" a map with the keys "important, content"
Important {{.important}} Important {{.important}}
{{.content}} {{.content}}
or create a map on the fly to pass into or create a map on the fly to pass into
{{partial "foo" (dict "important" "Smiles" "content" "You should do more")}} {{partial "foo" (dict "important" "Smiles" "content" "You should do more")}}
@ -313,6 +312,15 @@ Following operators are now available
- `<`, `lt`: True if a given field value is lesser than a matching value - `<`, `lt`: True if a given field value is lesser than a matching value
- `in`: True if a given field value is included in a matching value. A matching value must be an array or a slice - `in`: True if a given field value is included in a matching value. A matching value must be an array or a slice
- `not in`: True if a given field value isn't included in a matching value. A matching value must be an array or a slice - `not in`: True if a given field value isn't included in a matching value. A matching value must be an array or a slice
- `intersect`: True if a given field value that is a slice / array of strings or integers contains elements in common with the matching value. It follows the same rules as the intersect function.
*`intersect` operator, e.g.:*
{{ range where .Site.Pages ".Params.tags" "intersect" .Params.tags }}
{{ if ne .Permalink $.Permalink }}
{{ .Render "summary" }}
{{ end }}
{{ end }}
*`where` and `first` can be stacked, e.g.:* *`where` and `first` can be stacked, e.g.:*