iris/_examples/view/template_html_1/main.go
kataras 42b123975c 8.4.0 | New MVC Features | Refactor examples and godoc for go 1.9 use. Read HISTORY.md.
Former-commit-id: 90c05e743052bc3722e7fefaa0cbb0ed5153a1fb
2017-08-27 20:35:23 +03:00

30 lines
691 B
Go

package main
import (
"github.com/kataras/iris"
)
type mypage struct {
Title string
Message string
}
func main() {
app := iris.New()
app.RegisterView(iris.HTML("./templates", ".html").Layout("layout.html"))
// TIP: append .Reload(true) to reload the templates on each request.
app.Get("/", func(ctx iris.Context) {
ctx.Gzip(true)
ctx.ViewData("", mypage{"My Page title", "Hello world!"})
ctx.View("mypage.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
})
// http://localhost:8080
app.Run(iris.Addr(":8080"))
}