iris/_examples/view/template_html_5/main.go
Gerasimos (Makis) Maropoulos d451335aa2 gofmt
Former-commit-id: 75992b3aeae2228a7a7f0e698ce78b2f323cc33a
2019-01-20 00:00:54 +02:00

32 lines
751 B
Go

package main
import (
"github.com/kataras/iris"
)
func main() {
app := iris.New()
app.RegisterView(iris.HTML("./views", ".html").Layout("layout.html"))
// TIP: append .Reload(true) to reload the templates on each request.
app.Get("/home", func(ctx iris.Context) {
ctx.ViewData("title", "Home page")
ctx.View("home.html")
// Note that: you can pass "layout" : "otherLayout.html" to bypass the config's Layout property
// or view.NoLayout to disable layout on this render action.
// third is an optional parameter
})
app.Get("/about", func(ctx iris.Context) {
ctx.View("about.html")
})
app.Get("/user/index", func(ctx iris.Context) {
ctx.View("user/index.html")
})
// http://localhost:8080
app.Run(iris.Addr(":8080"))
}