Comments (4)
I submitted PR #104 to fix this issue. The PR introduces a new function NewFileSystemPartials
which takes a Filesystem specially for partials (of course a user instead can also use the same Filesystem already used for the other template files). If the partialFileSystem
is set the above call to mustache.ParseString
is replaced with a call to mustache.ParseStringPartials
that uses the embedded Filesystem for the partials.
Feel free to adapt the PR.
from template.
hi i tried it myself, with partials in the embedded filesystem and it seems to work, without any adjustments
package main
import (
"embed"
"log"
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/mustache"
)
//go:embed views/*
var viewsfs embed.FS
func main() {
engine := mustache.NewFileSystem(
http.FS(viewsfs),
".mustache",
)
// Pass the engine to the Views
app := fiber.New(fiber.Config{
Views: engine,
})
app.Get("/", func(c *fiber.Ctx) error {
// Render index
return c.Render("views/index", fiber.Map{
"Title": "Hello, World!",
})
})
log.Fatal(app.Listen(":3000"))
}
views folder from here:
https://github.com/gofiber/template/tree/master/mustache/views
from template.
It only works if / because the files are (also) available on the real filesystem on the correct (expected) paths. If you run the binary from a different location, the paths are not as expected anymore and it will not find the partials, which results in only rendering the Hello, World!
.
I'll update the PR with the requested changes.
from template.
ok, thx
from template.
Related Issues (20)
- [Improvement]: 🚀 Interface for the template engines HOT 2
- [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
- 🐛 [Bug]: Mustache template engine; partials don't work HOT 8
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.