hugolib: Rename Page.Equals to Page.Eq

To get the name in line with the template func `eq`.
This commit is contained in:
Bjørn Erik Pedersen 2017-08-16 10:01:16 +02:00
parent f0f49ed9b0
commit c265c102ae
2 changed files with 5 additions and 5 deletions

View file

@ -109,10 +109,10 @@ func (p *Page) IsAncestor(other interface{}) (bool, error) {
return helpers.HasStringsPrefix(pp.sections, p.sections), nil return helpers.HasStringsPrefix(pp.sections, p.sections), nil
} }
// Equals returns whether the current page equals the given page. // Eq returns whether the current page equals the given page.
// Note that this is more accurate than doing `{{ if eq $page $otherPage }}` // Note that this is more accurate than doing `{{ if eq $page $otherPage }}`
// since a Page can be embedded in another type. // since a Page can be embedded in another type.
func (p *Page) Equals(other interface{}) (bool, error) { func (p *Page) Eq(other interface{}) (bool, error) {
pp, err := unwrapPage(other) pp, err := unwrapPage(other)
if err != nil { if err != nil {
return false, err return false, err

View file

@ -150,13 +150,13 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
assert.NotNil(d) assert.NotNil(d)
assert.Equal("T41_-1", d.Title) assert.Equal("T41_-1", d.Title)
equals, err := c.Equals(d) equals, err := c.Eq(d)
assert.NoError(err) assert.NoError(err)
assert.False(equals) assert.False(equals)
equals, err = c.Equals(c) equals, err = c.Eq(c)
assert.NoError(err) assert.NoError(err)
assert.True(equals) assert.True(equals)
_, err = c.Equals("asdf") _, err = c.Eq("asdf")
assert.Error(err) assert.Error(err)
}}, }},