iris/_examples/view/template_ace_0/main.go
2020-08-03 05:46:04 +03:00

32 lines
790 B
Go

package main
import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
// Read about its markup syntax at: https://github.com/yosssi/ace
tmpl := iris.Ace("./views", ".ace")
// tmpl.Layout("layouts/main.ace") -> global layout for all pages.
app.RegisterView(tmpl)
app.Get("/", func(ctx iris.Context) {
ctx.View("index.ace", iris.Map{
"Title": "Title of The Page",
})
})
app.Get("/layout", func(ctx iris.Context) {
ctx.ViewLayout("layouts/main.ace") // layout for that response.
ctx.View("index.ace", iris.Map{
"Title": "Title of the main Page",
})
})
// otherGroup := app.Party("/other").Layout("layouts/other.ace") -> layout for that party.
// otherGroup.Get("/", func(ctx iris.Context) { ctx.View("index.ace", [...]) })
app.Listen(":8080")
}