gofiber / gofiber/template

html.Engine will stop reading templates after first error

Open
#191 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

☢️ Bug
Dominant language
Go
Stars
314
Forks
61
Avg merge
4h 35m
Merged PRs (30d)
12

Description

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)
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior through html.NewFileSystem with the embedded templates from templates.GetFiles(), including an invalid {{ ItDoesNotExists }} action. Inspect how htmlEngine.Templates.Templates() is populated after the first template error; done means later templates such as 4.html are still loaded and the error behavior is explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.