From b05aaed14dde1aea4b5e8368b15796ad13f19358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 2 Apr 2018 18:47:48 +0200 Subject: [PATCH] Update where.md --- content/functions/where.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 }}