kuvia2/vendor/github.com/flamego/template
2022-01-15 00:09:03 +01:00
..
testdata Init 2022-01-15 00:09:03 +01:00
.gitignore Init 2022-01-15 00:09:03 +01:00
.golangci.yml Init 2022-01-15 00:09:03 +01:00
codecov.yml Init 2022-01-15 00:09:03 +01:00
file_system.go Init 2022-01-15 00:09:03 +01:00
LICENSE Init 2022-01-15 00:09:03 +01:00
README.md Init 2022-01-15 00:09:03 +01:00
template.go Init 2022-01-15 00:09:03 +01:00

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.16.

go get github.com/flamego/template

Getting started

<!-- templates/home.tmpl -->
<p>
  Hello, <b>{{.Name}}</b>!
</p>
package main

import (
	"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.