iris/_examples/view/template_pug_0/main.go
Gerasimos (Makis) Maropoulos e1f25eb098
Full support of the http.FileSystem on all view engines as requested at #1575
Also, the HandleDir accepts both string and http.FileSystem (interface{}) (like the view's fs)
2020-09-05 08:34:09 +03:00

43 lines
803 B
Go

// Package main shows an example of pug actions based on https://github.com/Joker/jade/tree/master/example/actions
package main
import "github.com/kataras/iris/v12"
type Person struct {
Name string
Age int
Emails []string
Jobs []*Job
}
type Job struct {
Employer string
Role string
}
func main() {
app := iris.New()
tmpl := iris.Pug("./templates", ".pug")
app.RegisterView(tmpl)
app.Get("/", index)
// http://localhost:8080
app.Listen(":8080")
}
func index(ctx iris.Context) {
job1 := Job{Employer: "Monash B", Role: "Honorary"}
job2 := Job{Employer: "Box Hill", Role: "Head of HE"}
person := Person{
Name: "jan",
Age: 50,
Emails: []string{"jan@newmarch.name", "jan.newmarch@gmail.com"},
Jobs: []*Job{&job1, &job2},
}
ctx.View("index.pug", person)
}