iris/_examples/view/template_pug_0/main.go
Gerasimos (Makis) Maropoulos 3945fa68d1 obey the vote of @1370 (77-111 at this point) - add import suffix on iris repository
We have to do the same on iris-contrib/examples, iris-contrib/middleware and e.t.c.


Former-commit-id: 0860688158f374bc137bc934b81b26dcd0e10964
2019-10-25 01:27:02 +03:00

29 lines
701 B
Go

package main
import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
tmpl := iris.Pug("./templates", ".pug")
tmpl.Reload(true) // reload templates on each request (development mode)
tmpl.AddFunc("greet", func(s string) string { // add your template func here.
return "Greetings " + s + "!"
})
app.RegisterView(tmpl)
app.Get("/", index)
// http://localhost:8080
app.Run(iris.Addr(":8080"))
}
func index(ctx iris.Context) {
ctx.ViewData("pageTitle", "My Index Page")
ctx.ViewData("youAreUsingJade", true)
// Q: why need extension .pug?
// A: Because you can register more than one view engine per Iris application.
ctx.View("index.pug")
}