From c3d83149af115cdcb6e3f2079436f00622ff8a63 Mon Sep 17 00:00:00 2001 From: Bradley Nelson Date: Wed, 22 May 2019 23:24:01 -0600 Subject: [PATCH] Boolean Values in the Where Function This caused me some trouble should seem oblivious but would have saved me some time. Maybe it will save some others. --- content/en/functions/where.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/content/en/functions/where.md b/content/en/functions/where.md index 29623c908..ece4acb21 100644 --- a/content/en/functions/where.md +++ b/content/en/functions/where.md @@ -83,6 +83,15 @@ The following logical operators are available with `where`: `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]. +## Use `where` with `Booleans` +When using booleans you should not put quotation marks. +```go-html-template +{{range where .Pages ".Draft" true}} +

{{.Title}}

+{{end}} +``` + + ## Use `where` with `intersect` ```go-html-template @@ -122,7 +131,7 @@ then ranges through only the first 5 posts in that list: 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 .Pages "Section" "blog" ) ".Params.featured" "!=" "true" }} +{{ range where (where .Pages "Section" "blog" ) ".Params.featured" "!=" true }} ``` ## Unset Fields