Files
gf/.example/os/gview/object/object.go

29 lines
435 B
Go
Raw Normal View History

2018-11-03 15:59:24 +08:00
package main
import (
2019-07-29 21:01:19 +08:00
"github.com/gogf/gf/frame/g"
2018-11-03 15:59:24 +08:00
)
type T struct {
2019-04-03 00:03:46 +08:00
Name string
2018-11-03 15:59:24 +08:00
}
func (t *T) Hello(name string) string {
2019-04-03 00:03:46 +08:00
return "Hello " + name
2018-11-03 15:59:24 +08:00
}
func (t *T) Test() string {
2019-04-03 00:03:46 +08:00
return "This is test"
2018-11-03 15:59:24 +08:00
}
func main() {
2019-04-03 00:03:46 +08:00
t := &T{"John"}
v := g.View()
content := `{{.t.Hello "there"}}, my name's {{.t.Name}}. {{.t.Test}}.`
if r, err := v.ParseContent(content, g.Map{"t": t}); err != nil {
g.Dump(err)
} else {
g.Dump(r)
}
2018-11-03 15:59:24 +08:00
}