From: Bjørn Erik Pedersen Date: Thu, 17 Aug 2017 07:43:39 +0000 (+0200) Subject: hugolib: Simplify Page.Eq X-Git-Tag: v0.27~23 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2a2e690707bcce8e3a157113356ebca572bc1be6;p=brevno-suite%2Fhugo hugolib: Simplify Page.Eq --- diff --git a/hugolib/site_sections.go b/hugolib/site_sections.go index 25731e9d..1a42f780 100644 --- a/hugolib/site_sections.go +++ b/hugolib/site_sections.go @@ -112,14 +112,13 @@ func (p *Page) IsAncestor(other interface{}) (bool, error) { // Eq returns whether the current page equals the given page. // Note that this is more accurate than doing `{{ if eq $page $otherPage }}` // since a Page can be embedded in another type. -func (p *Page) Eq(other interface{}) (bool, error) { +func (p *Page) Eq(other interface{}) bool { pp, err := unwrapPage(other) if err != nil { - // Do not return an error on type mismatch. - return false, nil + return false } - return p == pp, nil + return p == pp } func unwrapPage(in interface{}) (*Page, error) { diff --git a/hugolib/site_sections_test.go b/hugolib/site_sections_test.go index 355b74bb..37752467 100644 --- a/hugolib/site_sections_test.go +++ b/hugolib/site_sections_test.go @@ -150,14 +150,9 @@ PAG|{{ .Title }}|{{ $sect.InSection . }} assert.NotNil(d) assert.Equal("T41_-1", d.Title) - equals, err := c.Eq(d) - assert.NoError(err) - assert.False(equals) - equals, err = c.Eq(c) - assert.NoError(err) - assert.True(equals) - _, err = c.Eq("asdf") - assert.Error(err) + assert.False(c.Eq(d)) + assert.True(c.Eq(c)) + assert.False(c.Eq("asdf")) }}, {"empty3", func(p *Page) {