b6f06a55 by astaxie

add template can't find template file

1 parent 0172c6c1
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
6 "compress/zlib" 6 "compress/zlib"
7 "encoding/json" 7 "encoding/json"
8 "encoding/xml" 8 "encoding/xml"
9 "errors"
9 "github.com/astaxie/beego/session" 10 "github.com/astaxie/beego/session"
10 "html/template" 11 "html/template"
11 "io" 12 "io"
...@@ -148,6 +149,10 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -148,6 +149,10 @@ func (c *Controller) RenderBytes() ([]byte, error) {
148 subdir := path.Dir(c.TplNames) 149 subdir := path.Dir(c.TplNames)
149 _, file := path.Split(c.TplNames) 150 _, file := path.Split(c.TplNames)
150 newbytes := bytes.NewBufferString("") 151 newbytes := bytes.NewBufferString("")
152 if _, ok := BeeTemplates[subdir]; !ok {
153 panic("can't find templatefile in the path:" + c.TplNames)
154 return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
155 }
151 BeeTemplates[subdir].ExecuteTemplate(newbytes, file, c.Data) 156 BeeTemplates[subdir].ExecuteTemplate(newbytes, file, c.Data)
152 tplcontent, _ := ioutil.ReadAll(newbytes) 157 tplcontent, _ := ioutil.ReadAll(newbytes)
153 c.Data["LayoutContent"] = template.HTML(string(tplcontent)) 158 c.Data["LayoutContent"] = template.HTML(string(tplcontent))
...@@ -169,6 +174,10 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -169,6 +174,10 @@ func (c *Controller) RenderBytes() ([]byte, error) {
169 subdir := path.Dir(c.TplNames) 174 subdir := path.Dir(c.TplNames)
170 _, file := path.Split(c.TplNames) 175 _, file := path.Split(c.TplNames)
171 ibytes := bytes.NewBufferString("") 176 ibytes := bytes.NewBufferString("")
177 if _, ok := BeeTemplates[subdir]; !ok {
178 panic("can't find templatefile in the path:" + c.TplNames)
179 return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
180 }
172 err := BeeTemplates[subdir].ExecuteTemplate(ibytes, file, c.Data) 181 err := BeeTemplates[subdir].ExecuteTemplate(ibytes, file, c.Data)
173 if err != nil { 182 if err != nil {
174 Trace("template Execute err:", err) 183 Trace("template Execute err:", err)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!