mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-27 21:10:51 +00:00
hugolib: Allow nil to be unwrapped as *Page
Previously, calls to *Page.Eq(nil) would always return false because the unwrapPage func didn't support the nil case. Add support for unwrapping nil to a *Page. Fixes #5043
This commit is contained in:
parent
10ac2ec446
commit
498d629958
2 changed files with 7 additions and 0 deletions
|
@ -152,6 +152,8 @@ func unwrapPage(in interface{}) (*Page, error) {
|
|||
return v.Page, nil
|
||||
case *PageWithoutContent:
|
||||
return v.Page, nil
|
||||
case nil:
|
||||
return nil, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("%T not supported", in)
|
||||
}
|
||||
|
|
|
@ -166,6 +166,11 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
|
|||
assert.Equal("empty3.md", b.Pages[0].File.LogicalName())
|
||||
|
||||
}},
|
||||
{"empty3", func(p *Page) {
|
||||
xxx := p.s.getPage(KindPage, "empty3", "nil")
|
||||
assert.Nil(xxx)
|
||||
assert.Equal(xxx.Eq(nil), true)
|
||||
}},
|
||||
{"top", func(p *Page) {
|
||||
assert.Equal("Tops", p.title)
|
||||
assert.Len(p.Pages, 2)
|
||||
|
|
Loading…
Reference in a new issue