return helpers.HasStringsPrefix(pp.sections, p.sections), nil
}
+// Equals 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) Equals(other interface{}) (bool, error) {
+ pp, err := unwrapPage(other)
+ if err != nil {
+ return false, err
+ }
+
+ return p == pp, nil
+}
+
func unwrapPage(in interface{}) (*Page, error) {
if po, ok := in.(*PageOutput); ok {
in = po.Page
d := p.s.getPage(KindSection, "empty2", "b", "c", "d")
assert.NotNil(d)
assert.Equal("T41_-1", d.Title)
+
+ equals, err := c.Equals(d)
+ assert.NoError(err)
+ assert.False(equals)
+ equals, err = c.Equals(c)
+ assert.NoError(err)
+ assert.True(equals)
+ _, err = c.Equals("asdf")
+ assert.Error(err)
+
}},
{"empty3", func(p *Page) {
// b,c,d with regular page in b