Adding proper error message when view is not found.. fixing #303
authorspf13 <steve.francia@gmail.com>
Wed, 4 Jun 2014 16:33:16 +0000 (12:33 -0400)
committerspf13 <steve.francia@gmail.com>
Wed, 4 Jun 2014 16:33:27 +0000 (12:33 -0400)
hugolib/page.go

index 5b33fc6c5d5a28f55c8436c592f6da01ce6bdf5d..f71ed2b042fbffb91d68b8f096c0a77309390e6f 100644 (file)
@@ -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
 }