From 96bc78478a94f0ae00bc6ee76e2aae881f99f454 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 14 Aug 2017 18:36:05 +0800 Subject: [PATCH] Fix Render --- template.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/template.go b/template.go index cb7fb98..12edfb6 100644 --- a/template.go +++ b/template.go @@ -92,7 +92,10 @@ func (tmpl *Template) Render(templateName string, obj interface{}, request *http funcMap["yield"] = func() (template.HTML, error) { return render(templateName) } layout := tmpl.layout + usingDefaultLayout := false + if layout == "" && tmpl.usingDefaultLayout { + usingDefaultLayout = true layout = tmpl.render.DefaultLayout } @@ -105,7 +108,7 @@ func (tmpl *Template) Render(templateName string, obj interface{}, request *http return template.HTML(tpl.String()), nil } } - } else { + } else if !usingDefaultLayout { err = fmt.Errorf("Failed to render layout: '%v.tmpl', got error: %v", filepath.Join("layouts", tmpl.layout), err) fmt.Println(err) return template.HTML(""), err