mirror of
https://gitee.com/johng/gf
synced 2026-06-23 16:34:17 +08:00
Merge branch 'master' of https://gitee.com/johng/gf
This commit is contained in:
28
geg/os/gview/object/object.go
Normal file
28
geg/os/gview/object/object.go
Normal file
@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitee.com/johng/gf/g"
|
||||
)
|
||||
|
||||
type T struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (t *T) Hello(name string) string {
|
||||
return "Hello " + name
|
||||
}
|
||||
|
||||
func (t *T) Test() string {
|
||||
return "This is test"
|
||||
}
|
||||
|
||||
func main() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user