Skip to content

Commit

Permalink
Adding proper error message when view is not found.. fixing #303
Browse files Browse the repository at this point in the history
  • Loading branch information
spf13 committed Jun 4, 2014
1 parent 640ab3c commit 4e99d6b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hugolib/page.go
Expand Up @@ -514,12 +514,18 @@ func (p *Page) Render(layout ...string) template.HTML {
func (p *Page) ExecuteTemplate(layout string) *bytes.Buffer {
l := p.Layout(layout)
buffer := new(bytes.Buffer)
worked := false
for _, layout := range l {
if p.Tmpl.Lookup(layout) != nil {
p.Tmpl.ExecuteTemplate(buffer, layout, p)
worked = true
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
}

Expand Down

0 comments on commit 4e99d6b

Please sign in to comment.