From 1c975b54dd1899fefec945f26ac250286c65edf1 Mon Sep 17 00:00:00 2001 From: Christophe de Carvalho Date: Thu, 3 Jul 2014 22:27:35 +0200 Subject: [PATCH] instanciate templates at engine creation this allow to use Delims() on HTMLTemplates before calling LoadHTMLTemplates() so we can change delimmiters in templates. --- gin.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gin.go b/gin.go index 197b98ca..e198e236 100644 --- a/gin.go +++ b/gin.go @@ -74,7 +74,9 @@ func (a ErrorMsgs) String() string { // Returns a new blank Engine instance without any middleware attached. // The most basic configuration func New() *Engine { - engine := &Engine{} + engine := &Engine{ + HTMLTemplates: template.New(""), + } engine.RouterGroup = &RouterGroup{nil, "/", nil, engine} engine.router = httprouter.New() engine.router.NotFound = engine.handle404 @@ -89,7 +91,7 @@ func Default() *Engine { } func (engine *Engine) LoadHTMLTemplates(pattern string) { - engine.HTMLTemplates = template.Must(template.ParseGlob(pattern)) + engine.HTMLTemplates = template.Must(engine.HTMLTemplates.ParseGlob(pattern)) } // Adds handlers for NotFound. It return a 404 code by default.