iris/_examples/view/template_amber_1_embedded/main.go

32 lines
806 B
Go
Raw Normal View History

package main
import "github.com/kataras/iris/v12"
2022-07-19 21:48:04 +02:00
// $ go install github.com/go-bindata/go-bindata/v3/go-bindata@latest
//
// $ go-bindata -fs -prefix "../template_amber_0/views" ../template_amber_0/views/...
// $ go run .
// # OR: go-bindata -fs -prefix "views" ./views/... if the views dir is rel to the executable.
//
// System files are not used, you can optionally delete the folder and run the example now.
func main() {
app := iris.New()
// Read about its markup syntax at: https://github.com/eknkc/amber
tmpl := iris.Amber(AssetFile(), ".amber")
app.RegisterView(tmpl)
app.Get("/", func(ctx iris.Context) {
if err := ctx.View("index.amber", iris.Map{
"Title": "Title of The Page",
}); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
})
app.Listen(":8080")
}