From 08f48b91d68d3002b887ddf737456ff0cc4e786d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 17 Aug 2017 10:24:17 +0200 Subject: 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 --- hugolib/page.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'hugolib') diff --git a/hugolib/page.go b/hugolib/page.go index 5de976bd4..c29590802 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -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 ( -- cgit v1.2.3