From 75a7ccc6a329d64fed94218ac5cb2e951f436412 Mon Sep 17 00:00:00 2001 From: Richard Burk Orofeo Date: Wed, 17 Feb 2021 21:27:29 +0800 Subject: [PATCH 1/3] added documentation for go embed package available in go 1.16 Signed-off-by: Richard Burk Orofeo --- README.md | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 199d9ba..cd59db3 100644 --- a/README.md +++ b/README.md @@ -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 @@ -226,4 +263,4 @@ func main() { // Read the documentation on how to use fileb0x } -``` \ No newline at end of file +``` From 7712919c7a67f7167fee484e35738793cc3fc8cd Mon Sep 17 00:00:00 2001 From: Richard Burk Orofeo Date: Wed, 17 Feb 2021 21:28:27 +0800 Subject: [PATCH 2/3] fixed formatting Signed-off-by: Richard Burk Orofeo --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cd59db3..32cc4e8 100644 --- a/README.md +++ b/README.md @@ -152,11 +152,11 @@ func main() { return } - engine := html.NewFileSystem(http.FS(webContent), ".html") +engine := html.NewFileSystem(http.FS(webContent), ".html") - app := fiber.New(fiber.Config{ - Views: engine, - }) +app := fiber.New(fiber.Config{ + Views: engine, +}) // rest of the code... } From 2a31576292746a80cae3693068a9716b51f45951 Mon Sep 17 00:00:00 2001 From: Richard Burk Orofeo Date: Wed, 17 Feb 2021 21:29:07 +0800 Subject: [PATCH 3/3] alignment problems Signed-off-by: Richard Burk Orofeo --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 32cc4e8..5cc5825 100644 --- a/README.md +++ b/README.md @@ -152,11 +152,11 @@ func main() { return } -engine := html.NewFileSystem(http.FS(webContent), ".html") + engine := html.NewFileSystem(http.FS(webContent), ".html") -app := fiber.New(fiber.Config{ - Views: engine, -}) + app := fiber.New(fiber.Config{ + Views: engine, + }) // rest of the code... }