mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-15 20:44:44 -04:00
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:
parent
26fe1ca2f8
commit
7d086adbd7
@ -79,7 +79,6 @@ e.g. Pass into "foo.html" a map with the keys "important, content"
|
||||
Important {{.important}}
|
||||
{{.content}}
|
||||
|
||||
|
||||
or create a map on the fly to pass into
|
||||
|
||||
{{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
|
||||
- `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
|
||||
- `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.:*
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user