Package template is a middleware that provides Go template rendering for Flamego.
The minimum requirement of Go is 1.18.
go get github.com/flamego/template
<!-- templates/home.tmpl -->
<p>
Hello, <b>{{.Name}}</b>!
</p>
package main
import (
"net/http"
"github.com/flamego/flamego"
"github.com/flamego/template"
)
func main() {
f := flamego.Classic()
f.Use(template.Templater())
f.Get("/", func(t template.Template, data template.Data) {
data["Name"] = "Joe"
t.HTML(http.StatusOK, "home")
})
f.Run()
}
- Read documentation and examples.
- Please file an issue or start a discussion on the flamego/flamego repository.
This project is under the MIT License. See the LICENSE file for the full license text.