Skip to content

Package template is a middleware that provides Go template rendering for Flamego

License

Notifications You must be signed in to change notification settings

flamego/template

Folders and files

NameName
Last commit message
Last commit date
Dec 2, 2024
May 15, 2021
Dec 8, 2021
May 15, 2021
Dec 2, 2024
May 15, 2021
Jul 23, 2023
May 15, 2021
Sep 14, 2021
Sep 14, 2021
Apr 2, 2025
Apr 2, 2025
Jul 23, 2023
Sep 14, 2021

Repository files navigation

template

GitHub Workflow Status Codecov GoDoc Sourcegraph

Package template is a middleware that provides Go template rendering for Flamego.

Installation

The minimum requirement of Go is 1.18.

go get github.com/flamego/template

Getting started

<!-- 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()
}

Getting help

License

This project is under the MIT License. See the LICENSE file for the full license text.