mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-13 12:15:59 -04:00
Update where.md
This commit is contained in:
parent
4d47608191
commit
b05aaed14d
@ -22,7 +22,7 @@ needsexample: true
|
||||
|
||||
`where` filters an array to only the elements containing a matching value for a given field.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ range where .Data.Pages "Section" "post" }}
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
@ -44,7 +44,7 @@ series: golang
|
||||
|
||||
It can also be used with the logical operators `!=`, `>=`, `in`, etc. Without an operator, `where` compares a given field with a matching value equivalent to `=`.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ range where .Data.Pages "Section" "!=" "post" }}
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
@ -81,7 +81,7 @@ The following logical operators are available with `where`:
|
||||
|
||||
## Use `where` with `intersect`
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ range where .Site.Pages ".Params.tags" "intersect" .Params.tags }}
|
||||
{{ if ne .Permalink $.Permalink }}
|
||||
{{ .Render "summary" }}
|
||||
@ -113,7 +113,7 @@ The following grabs the first five content files in `post` using the [default or
|
||||
|
||||
You can also nest `where` clauses to drill down on lists of content by more than one parameter. The following first grabs all pages in the "blog" section and then ranges through the result of the first `where` clause and finds all pages that are *not* featured:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ range where (where .Data.Pages "Section" "blog" ) ".Params.featured" "!=" "true" }}
|
||||
```
|
||||
|
||||
@ -128,7 +128,7 @@ Only the following operators are available for `nil`
|
||||
* `=`, `==`, `eq`: True if the given field is not set.
|
||||
* `!=`, `<>`, `ne`: True if the given field is set.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ range where .Data.Pages ".Params.specialpost" "!=" nil }}
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user