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

Added Support for go 1.16 embed package #93

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,43 @@ To view more specific examples, you could visit each engine folder to learn more

We support the `http.FileSystem` interface, so you can use different libraries to load the templates from embedded binaries.

#### go 1.16 embed package
> Requires atleast Go 1.16

Read documentation: https://golang.org/pkg/embed
```go
package main

import (
"embed"
"io/fs"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html"
)

//go:embed views
var content embed.FS

func main() {
fsys := fs.FS(content)
webContent, err := fs.Sub(fsys, "views")
if err != nil {
// handle err
return
}

engine := html.NewFileSystem(http.FS(webContent), ".html")

app := fiber.New(fiber.Config{
Views: engine,
})

// rest of the code...
}
```


#### pkger
Read documentation: https://github.com/markbates/pkger

Expand Down Expand Up @@ -226,4 +263,4 @@ func main() {

// Read the documentation on how to use fileb0x
}
```
```