mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:30:56 +00:00
add template can't find template file
This commit is contained in:
parent
0172c6c104
commit
b6f06a5559
@ -6,6 +6,7 @@ import (
|
|||||||
"compress/zlib"
|
"compress/zlib"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"errors"
|
||||||
"github.com/astaxie/beego/session"
|
"github.com/astaxie/beego/session"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
@ -148,6 +149,10 @@ func (c *Controller) RenderBytes() ([]byte, error) {
|
|||||||
subdir := path.Dir(c.TplNames)
|
subdir := path.Dir(c.TplNames)
|
||||||
_, file := path.Split(c.TplNames)
|
_, file := path.Split(c.TplNames)
|
||||||
newbytes := bytes.NewBufferString("")
|
newbytes := bytes.NewBufferString("")
|
||||||
|
if _, ok := BeeTemplates[subdir]; !ok {
|
||||||
|
panic("can't find templatefile in the path:" + c.TplNames)
|
||||||
|
return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
|
||||||
|
}
|
||||||
BeeTemplates[subdir].ExecuteTemplate(newbytes, file, c.Data)
|
BeeTemplates[subdir].ExecuteTemplate(newbytes, file, c.Data)
|
||||||
tplcontent, _ := ioutil.ReadAll(newbytes)
|
tplcontent, _ := ioutil.ReadAll(newbytes)
|
||||||
c.Data["LayoutContent"] = template.HTML(string(tplcontent))
|
c.Data["LayoutContent"] = template.HTML(string(tplcontent))
|
||||||
@ -169,6 +174,10 @@ func (c *Controller) RenderBytes() ([]byte, error) {
|
|||||||
subdir := path.Dir(c.TplNames)
|
subdir := path.Dir(c.TplNames)
|
||||||
_, file := path.Split(c.TplNames)
|
_, file := path.Split(c.TplNames)
|
||||||
ibytes := bytes.NewBufferString("")
|
ibytes := bytes.NewBufferString("")
|
||||||
|
if _, ok := BeeTemplates[subdir]; !ok {
|
||||||
|
panic("can't find templatefile in the path:" + c.TplNames)
|
||||||
|
return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
|
||||||
|
}
|
||||||
err := BeeTemplates[subdir].ExecuteTemplate(ibytes, file, c.Data)
|
err := BeeTemplates[subdir].ExecuteTemplate(ibytes, file, c.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Trace("template Execute err:", err)
|
Trace("template Execute err:", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user