gofiber/template hiện có 313 sao trên GitHub, viết chủ yếu bằng Go. 🧬 Template engine middleware for Fiber
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
This package provides universal methods to use multiple template engines with the Fiber web framework using the new Views interface that is available from > v1.11.1. Special thanks to @bdtomlin & @arsmn for helping!
9 template engines are supported:
ace
amber
django
handlebars
html
jet
mustache
pug
slim
Installation
Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information.
go get -u github.com/gofiber/fiber/v3
go get -u github.com/gofiber/template/any_template_engine/vX
Example
package main
import (
"log"
"github.com/gofiber/fiber/v3"
// To use a specific template engine, import as shown below:
// "github.com/gofiber/template/pug/v3"
// "github.com/gofiber/template/mustache/v3"
// etc..
// In this example we use the html template engine
"github.com/gofiber/template/html/v3"
)
func main() {
// Create a new engine by passing the template folder
// and template extension using <engine>.New(dir, ext string)
engine := html.New("./views", ".html")
// We also support the http.FileSystem interface
// See examples below to load templates from embedded files
engine := html.NewFileSystem(http.Dir("./views"), ".html")
// Reload the templates on each render, good for development
engine.Reload(true) // Optional. Default: false
// Debug will print each template that is parsed, good for debugging
engine.Debug(true) // Optional. Default: false
// Layout defines the variable name that is used to yield templates within layouts
engine.Layout("embed") // Optional. Default: "embed"
// Delims sets the action delimiters to the specified strings
engine.Delims("{{", "}}") // Optional. Default: engine delimiters
// AddFunc adds a function to the template's global function map.
engine.AddFunc("greet", func(name string) string {
return "Hello, " + name + "!"
})
// After you created your engine, you can pass it to Fiber's Views Engine
app := fiber.New(fiber.Config{
Views: engine,
})
// To render a template, you can call the ctx.Render function
// Render(tmpl string, values interface{}, layout ...string)
app.Get("/", func(c fiber.Ctx) error {
return c.Render("index", fiber.Map{
"Title": "Hello, World!",
})
})
// Render with layout example
app.Get("/layout", func(c fiber.Ctx) error {
return c.Render("index", fiber.Map{
"Title": "Hello, World!",
}, "layouts/main")
})
log.Fatal(app.Listen(":3000"))
}
More Examples
To view more specific examples, you could visit each engine folder to learn more
ace
amber
django
handlebars
html
jet
mustache
pug
slim
embedded Systems
We support the http.FileSystem interface, so you can use different libraries to load the templates from embedded binaries.
package main
import (
"log"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/template/html/v3"
// your generated package
"github.com/<user>/<repo>/static"
)
func main() {
engine := html.NewFileSystem(static.HTTP, ".html")
app := fiber.New(fiber.Config{
Views: engine,
})
// Read the documentation on how to use fileb0x
}
Benchmarks
See the benchmarks under https://gofiber.github.io/template/benchmarks
Simple
Extended
Benchmarks were ran on Apple Macbook M1. Each engine was benchmarked 20 times and the results averaged into a single xlsx file. Mustache was excluded from the extended benchmark
☕ Supporters
Fiber is an open-source project that runs on donations to pay the bills, e.g., our domain name, hosting, and serverless infrastructure. If you want to support Fiber, please become a GitHub Sponsor.
Tool Sponsors - supporting Fiber with free IDE licenses and AI credits
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/gofiber/template là nguồn chính thức.
gofiber/template có bao nhiêu sao?
gofiber/template có 313 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/gofiber/template. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
gofiber/template có những chủ đề gì?
GitHub topics của gofiber/template: "fiber", "middleware", "template", "template-engine". TopGit xếp repo vào nhóm Developer Tools.
gofiber/template có trang demo không?
Dự án có trang chủ ở https://docs.gofiber.io/guide/templates. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
gofiber/template còn đang phát triển không?
Commit gần nhất trên gofiber/template là 6 ngày trước (theo timestamp GitHub). Repo có 61 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
gofiber/template dùng license gì?
gofiber/template phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
gofiber/template viết bằng ngôn ngữ gì?
gofiber/template chủ yếu viết bằng Go. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
template có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về template.