Skip to content

Commit

Permalink
Improve reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenny committed Jun 17, 2020
1 parent b7bac4d commit 7dc2282
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions amber/amber.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func New(directory, extension string) *Engine {
extension: extension,
layout: "embed",
funcmap: make(map[string]interface{}),
Templates: make(map[string]*template.Template),
}
engine.AddFunc(engine.layout, func() error {
return fmt.Errorf("layout called unexpectedly.")
Expand All @@ -58,7 +57,6 @@ func NewFileSystem(fs http.FileSystem, extension string) *Engine {
extension: extension,
layout: "embed",
funcmap: make(map[string]interface{}),
Templates: make(map[string]*template.Template),
}
engine.AddFunc(engine.layout, func() error {
return fmt.Errorf("layout called unexpectedly.")
Expand Down Expand Up @@ -115,6 +113,8 @@ func (e *Engine) Load() error {
e.mutex.Lock()
defer e.mutex.Unlock()

e.Templates = make(map[string]*template.Template)

// Set template settings
// prepare the global amber funcs
funcs := template.FuncMap{}
Expand Down
5 changes: 3 additions & 2 deletions mustache/mustache.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func New(directory, extension string) *Engine {
directory: directory,
extension: extension,
layout: "embed",
Templates: make(map[string]*mustache.Template),
}
return engine
}
Expand All @@ -51,7 +50,6 @@ func NewFileSystem(fs http.FileSystem, extension string) *Engine {
fileSystem: fs,
extension: extension,
layout: "embed",
Templates: make(map[string]*mustache.Template),
}
return engine
}
Expand Down Expand Up @@ -95,6 +93,9 @@ func (e *Engine) Load() error {
// race safe
e.mutex.Lock()
defer e.mutex.Unlock()

e.Templates = make(map[string]*mustache.Template)

// Loop trough each directory and register template files
walkFn := func(path string, info os.FileInfo, err error) error {
// Return error if exist
Expand Down
1 change: 0 additions & 1 deletion pug/pug.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func NewFileSystem(fs http.FileSystem, extension string) *Engine {
extension: extension,
layout: "embed",
funcmap: make(map[string]interface{}),
Templates: template.New("/"),
}
engine.AddFunc(engine.layout, func() error {
return fmt.Errorf("layout called unexpectedly.")
Expand Down

0 comments on commit 7dc2282

Please sign in to comment.