mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-18 15:04:37 +00:00
Adding proper error message when view is not found.. fixing #303
This commit is contained in:
parent
640ab3c72e
commit
4e99d6b54c
1 changed files with 6 additions and 0 deletions
|
@ -514,12 +514,18 @@ func (p *Page) Render(layout ...string) template.HTML {
|
||||||
func (p *Page) ExecuteTemplate(layout string) *bytes.Buffer {
|
func (p *Page) ExecuteTemplate(layout string) *bytes.Buffer {
|
||||||
l := p.Layout(layout)
|
l := p.Layout(layout)
|
||||||
buffer := new(bytes.Buffer)
|
buffer := new(bytes.Buffer)
|
||||||
|
worked := false
|
||||||
for _, layout := range l {
|
for _, layout := range l {
|
||||||
if p.Tmpl.Lookup(layout) != nil {
|
if p.Tmpl.Lookup(layout) != nil {
|
||||||
p.Tmpl.ExecuteTemplate(buffer, layout, p)
|
p.Tmpl.ExecuteTemplate(buffer, layout, p)
|
||||||
|
worked = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !worked {
|
||||||
|
jww.ERROR.Println("Unable to render", layout, ".")
|
||||||
|
jww.ERROR.Println("Expecting to find a template in either the theme/layouts or /layouts in one of the following relative locations", l)
|
||||||
|
}
|
||||||
return buffer
|
return buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue