html.Engine will stop reading templates after first error
marosiak opened this issue · 2 comments
marosiak commented
Hi, today I had weird issue, I have registered templates, then seen 1 error in console about one of the templates, but application didn't fail, it worked but didn't load more templates.
1.html
2.html
3.html // Lets say this template is broken, 4 wont be loaded, but the app will behave like it's ok
4.html
How to reproduce?
htmlEngine := html.NewFileSystem(templates.GetFiles(), ".html")
app := fiber.New(fiber.Config{
Views: htmlEngine,
})
for _, v := range htmlEngine.Templates.Templates() {
println(v.Name())
}
now create package names templates
and put some html files, then in one of these files put {{ ItDoesNotExists }}
then create .go file with code below:
package templates
//go:embed *.html
var content embed.FS
func GetFiles() http.FileSystem {
return http.FS(content)
}
marosiak commented
It’d be great if the engine could return an error and let me decide if I want to panic() or run application without some parts working correctly