Comments (8)
@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?
from template.
Pls also share your setup code
from template.
@ReneWerner87 Sorry that was not the best written bug report, I was doing it away from home on my mobile.
Fiber version is v2.52.4
, I've not looked at v3 since I it's not production ready.
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:
serve>
views>
index.mustache
partials>
header.mustache
footer.mustache
layouts>
main.mustache
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:
2024/05/06 14:39:01 views: parsed template: index
2024/05/06 14:39:01 views: parsed template: layouts/main
2024/05/06 14:39:01 views: parsed template: partials/footer
2024/05/06 14:39:01 views: parsed template: partials/header
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:
return c.Render(
"index",
fiber.Map{},
"layouts/main",
)
from template.
Also it's not lost on me that when I wrote Created a project that mirrors the example in the Fiber Mustache docs.
its not accurate because I used additional path elements.
from template.
thanks we will test it with your code
from template.
from template.
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:
we will add some docus and try to improve our rendering info
from template.
thx for the report
from template.
Related Issues (20)
- [Improvement]: 🚀 Better benchmark statistic HOT 1
- 🐛 [Bug]: Draft new release version for template as well
- 🐛 [Bug]: django is broken after v3.1.0 HOT 2
- 🐛 [Bug]: HOT 2
- 🐛 [Bug]: v1.8.2 appears to be missing github.com/gofiber/template/html HOT 2
- 🚀 [Feature]: htmx support HOT 10
- 🐛 [Bug]: Django (pongo2) integration vulnerability to XSS HOT 10
- 🤗 [Question]: How can i divide my layout, component and views folders HOT 4
- 🤗 [Question]: How to export mustache engine as a template.IEngine ? HOT 1
- 🚀 [Feature]: Templ support? HOT 19
- 🐛 [Bug]: Module doesnt contain package HOT 3
- 🤗 [Question]: Why Mustache was excluded from the extended benchmark HOT 3
- fiber/django template uses its own non-standard `{{embed}}` tag.
- 🤗 [Question]: Is it possible to use django/v3 on gofiber/v3.0.0-beta? HOT 9
- 🐛 [Bug]: request fail before the template is available HOT 5
- 🐛 [Bug]: Jet, inside {{ embed() }} no error propagation HOT 2
- 🤗 [Question]: HOT 4
- 🐛 [Bug]: Template layout always show last loaded page. HOT 5
- 🤗 [Question]: How do I render conditionals in Pug HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from template.