diff --git a/content/functions/where.md b/content/functions/where.md index e989ba352..03767f54d 100644 --- a/content/functions/where.md +++ b/content/functions/where.md @@ -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 }}