iris/_examples/view/template_html_1/main.go
Gerasimos (Makis) Maropoulos d697426cb6 minor
Change the new ctx.Compres to ctx.CompressWriter and iris.Compress and iris.CompressReader as one iris.Compression

Update the README example

(master development branch)


Former-commit-id: fb67858fe5be5662b5816df41020c28ff9a8c6f6
2020-07-20 13:36:39 +03:00

30 lines
697 B
Go

package main
import (
"github.com/kataras/iris/v12"
)
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.CompressWriter(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.Listen(":8080")
}