diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-08-17 10:24:17 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-08-18 07:36:32 +0200 |
commit | 08f48b91d68d3002b887ddf737456ff0cc4e786d (patch) | |
tree | d0f37154d11cc6f5ab8d543d025e708cdc9f4acc /hugolib | |
parent | 2fc121ce2308b090ab67cbeb3039c53f5eedaa64 (diff) |
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
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/page.go | 5 |
1 files changed, 5 insertions, 0 deletions
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 ( |