github.com/gogf/gf@v1.16.9/.example/os/gview/define/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gogf/gf/frame/g"
     7  	"github.com/gogf/gf/os/gfile"
     8  )
     9  
    10  func main() {
    11  	v := g.View()
    12  	v.AddPath(gfile.MainPkgPath() + gfile.Separator + "template")
    13  	b, err := v.Parse("index.html", map[string]interface{}{
    14  		"k": "v",
    15  	})
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  	fmt.Println(string(b))
    20  
    21  }