mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
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)
This commit is contained in:
@@ -1,24 +1,20 @@
|
||||
// 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"
|
||||
import (
|
||||
"html/template"
|
||||
|
||||
type Person struct {
|
||||
Name string
|
||||
Age int
|
||||
Emails []string
|
||||
Jobs []*Job
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
Employer string
|
||||
Role string
|
||||
}
|
||||
"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("bold", func(s string) (template.HTML, error) { // add your template func here.
|
||||
return template.HTML("<b>" + s + "</b>"), nil
|
||||
})
|
||||
|
||||
app.RegisterView(tmpl)
|
||||
|
||||
app.Get("/", index)
|
||||
@@ -28,15 +24,5 @@ func main() {
|
||||
}
|
||||
|
||||
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)
|
||||
ctx.View("index.pug")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user