github.com/gogf/gf@v1.16.9/.example/os/gview/build_in_funcs/build_in_funcs1.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/gogf/gf/frame/g" 7 ) 8 9 func main() { 10 tplContent := ` 11 {{"<div>测试</div>"|text}} 12 {{"<div>测试</div>"|html}} 13 {{"<div>测试</div>"|htmldecode}} 14 {{"https://goframe.org"|url}} 15 {{"https%3A%2F%2Fgoframe.org"|urldecode}} 16 {{1540822968 | date "Y-m-d"}} 17 {{"1540822968" | date "Y-m-d H:i:s"}} 18 {{date "Y-m-d H:i:s"}} 19 {{compare "A" "B"}} 20 {{compare "1" "2"}} 21 {{compare 2 1}} 22 {{compare 1 1}} 23 {{"我是中国人" | substr 2 -1}} 24 {{"我是中国人" | substr 2 2}} 25 {{"我是中国人" | strlimit 2 "..."}} 26 {{"热爱GF热爱生活" | hidestr 20 "*"}} 27 {{"热爱GF热爱生活" | hidestr 50 "*"}} 28 {{"热爱GF热爱生活" | highlight "GF" "red"}} 29 {{"gf" | toupper}} 30 {{"GF" | tolower}} 31 {{"Go\nFrame" | nl2br}} 32 ` 33 content, err := g.View().ParseContent(tplContent, nil) 34 fmt.Println(err) 35 fmt.Println(string(content)) 36 }