compare, hugolib, tpl: Add Eqer interface

And use it in `eq` and `ne` so `Page` values can be compared directly in the templates without thinking about it being a `Page` or a `PageOutput` wrapper.

Fixes #3807
This commit is contained in:
Bjørn Erik Pedersen
2017-08-17 10:24:17 +02:00
parent 2fc121ce23
commit 08f48b91d6
4 changed files with 59 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ import (
"unicode/utf8"
bp "github.com/gohugoio/hugo/bufferpool"
"github.com/gohugoio/hugo/compare"
"github.com/gohugoio/hugo/source"
"github.com/spf13/cast"
)
@@ -49,6 +50,10 @@ var (
allKindsInPages = []string{KindPage, KindHome, KindSection, KindTaxonomy, KindTaxonomyTerm}
allKinds = append(allKindsInPages, []string{kindRSS, kindSitemap, kindRobotsTXT, kind404}...)
// Assert that it implements the Eqer interface.
_ compare.Eqer = (*Page)(nil)
_ compare.Eqer = (*PageOutput)(nil)
)
const (