-
Notifications
You must be signed in to change notification settings - Fork 53
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
🐛 [Bug]: Mustache template engine; partials don't work #383
Comments
@Durandle46 which fiber version do you exactly use? Latest is v3 and this is not compatible with template at the moment or latest of v2? |
Pls also share your setup code |
@ReneWerner87 Sorry that was not the best written bug report, I was doing it away from home on my mobile. Fiber version is I've worked out what the issue is. The path requires the complete relative path, not the relative path to the base directory given to the template engine. So for example, setting up the engine with: Files:
engine := mustache.New("serve/views", ".mustache")
engine .Debug(true)
engine .Verbose = true and then using a partial with: {{> views/partials/header}} Doesn't work. No error in the logs about not finding the partial either, it silently fails. However doing: {{> serve/views/partials/header}} Does work. It's not at all obvious this is required, and the docs don't mention this. Since the engine has already been handed the base directory to operate from, one might assume the name/path given is relative to that. To make it even less obvious, the debug output when parsing all the templates at start-up chops the path off entirely, making it seem like you can reference them using those names/paths:
And lastly, since the engine does render the layouts and views using the short name/path, it makes no sense to expect the partials to require the complete relative path:
|
Also it's not lost on me that when I wrote |
thanks we will test it with your code |
we will add some docus and try to improve our rendering info |
thx for the report |
Bug Description
When using the Mustache template engine, partials don't appear to work and the engine does not produce any errors or output in the logs, even when using deliberately non-existent template names.
How to Reproduce
Using:
go version go1.22.2 windows/amd64
Using: latest version of Fiber and related modules (
go get -u ./...
)Expected Behavior
Partials rendered into the template.
Template package Version
v2.0.10
Code Snippet (optional)
Checklist:
The text was updated successfully, but these errors were encountered: