예제 #1
0
파일: template.go 프로젝트: yubo/falcon
func RenderTemplate(TplNames string, Data map[interface{}]interface{}) string {
	if beego.BConfig.RunMode == "dev" {
		beego.BuildTemplate(beego.BConfig.WebConfig.ViewsPath)
	}

	ibytes := bytes.NewBufferString("")
	err := beego.ExecuteTemplate(ibytes, TplNames, Data)
	if err != nil {
		beego.Trace("template Execute err:", err)
	}
	icontent, _ := ioutil.ReadAll(ibytes)
	return string(icontent)
}
예제 #2
0
func RenderTemplate(TplNames string, Data map[interface{}]interface{}) string {
	if beego.RunMode == "dev" {
		beego.BuildTemplate(beego.ViewsPath)
	}

	ibytes := bytes.NewBufferString("")
	if _, ok := beego.BeeTemplates[TplNames]; !ok {
		panic("can't find templatefile in the path:" + TplNames)
	}
	err := beego.BeeTemplates[TplNames].ExecuteTemplate(ibytes, TplNames, Data)
	if err != nil {
		beego.Trace("template Execute err:", err)
	}
	icontent, _ := ioutil.ReadAll(ibytes)
	return string(icontent)
}