mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +08:00
instanciate templates at engine creation
this allow to use Delims() on HTMLTemplates before calling LoadHTMLTemplates() so we can change delimmiters in templates.
This commit is contained in:
parent
5eb0e10a78
commit
1c975b54dd
6
gin.go
6
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user