Merge commit 'b6b37a1f00f808f3c0d2715f65ca2d3091f36495'

This commit is contained in:
Bjørn Erik Pedersen
2018-07-18 11:05:58 +02:00
106 changed files with 307 additions and 279 deletions

View File

@@ -23,7 +23,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" }}
{{ range where .Pages "Section" "post" }}
{{ .Content }}
{{ end }}
```
@@ -45,7 +45,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" }}
{{ range where .Pages "Section" "!=" "post" }}
{{ .Content }}
{{ end }}
```
@@ -104,7 +104,7 @@ You can also put the returned value of the `where` clauses into a variable:
The following grabs the first five content files in `post` using the [default ordering](/templates/lists/) for lists (i.e., `weight => date`):
{{< code file="where-with-first.html" >}}
{{ range first 5 (where .Data.Pages "Section" "post") }}
{{ range first 5 (where .Pages "Section" "post") }}
{{ .Content }}
{{ end }}
{{< /code >}}
@@ -114,7 +114,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" }}
{{ range where (where .Pages "Section" "blog" ) ".Params.featured" "!=" "true" }}
```
## Unset Fields
@@ -129,7 +129,7 @@ Only the following operators are available for `nil`
* `!=`, `<>`, `ne`: True if the given field is set.
```go-html-template
{{ range where .Data.Pages ".Params.specialpost" "!=" nil }}
{{ range where .Pages ".Params.specialpost" "!=" nil }}
{{ .Content }}
{{ end }}
```