Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html.Engine will stop reading templates after first error #191

Open
marosiak opened this issue Aug 20, 2022 · 2 comments
Open

html.Engine will stop reading templates after first error #191

marosiak opened this issue Aug 20, 2022 · 2 comments
Labels
☢️ Bug Something isn't working

Comments

@marosiak
Copy link

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
Copy link
Author

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

@ReneWerner87 ReneWerner87 added the ☢️ Bug Something isn't working label Aug 22, 2022
@snowboarder
Copy link

When you say the template is "broken" what exactly breaks the template?? I am trying to find an answer to my issue with the templates and cant find resources on this issue.... I wish the templating was a bit different but if I could get it working I think it would be ok.

template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☢️ Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants