mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 20:22:20 +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.
|
// Returns a new blank Engine instance without any middleware attached.
|
||||||
// The most basic configuration
|
// The most basic configuration
|
||||||
func New() *Engine {
|
func New() *Engine {
|
||||||
engine := &Engine{}
|
engine := &Engine{
|
||||||
|
HTMLTemplates: template.New(""),
|
||||||
|
}
|
||||||
engine.RouterGroup = &RouterGroup{nil, "/", nil, engine}
|
engine.RouterGroup = &RouterGroup{nil, "/", nil, engine}
|
||||||
engine.router = httprouter.New()
|
engine.router = httprouter.New()
|
||||||
engine.router.NotFound = engine.handle404
|
engine.router.NotFound = engine.handle404
|
||||||
@ -89,7 +91,7 @@ func Default() *Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (engine *Engine) LoadHTMLTemplates(pattern string) {
|
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.
|
// Adds handlers for NotFound. It return a 404 code by default.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user