mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 13:51:28 +00:00
Merge pull request #1848 from JessonChan/template_fix
make template execution be expected
This commit is contained in:
commit
ebdf4412b3
@ -208,7 +208,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
err = executeTemplate(&buf, sectionTpl, c.Data)
|
err = ExecuteTemplate(&buf, sectionTpl, c.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
executeTemplate(&buf, c.Layout, c.Data)
|
ExecuteTemplate(&buf, c.Layout, c.Data)
|
||||||
}
|
}
|
||||||
return buf.Bytes(), err
|
return buf.Bytes(), err
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ func (c *Controller) renderTemplate() (bytes.Buffer, error) {
|
|||||||
}
|
}
|
||||||
BuildTemplate(BConfig.WebConfig.ViewsPath, buildFiles...)
|
BuildTemplate(BConfig.WebConfig.ViewsPath, buildFiles...)
|
||||||
}
|
}
|
||||||
return buf, executeTemplate(&buf, c.TplName, c.Data)
|
return buf, ExecuteTemplate(&buf, c.TplName, c.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect sends the redirection response to url with status code.
|
// Redirect sends the redirection response to url with status code.
|
||||||
|
@ -41,7 +41,10 @@ var (
|
|||||||
beeTemplateEngines = map[string]templateHandler{}
|
beeTemplateEngines = map[string]templateHandler{}
|
||||||
)
|
)
|
||||||
|
|
||||||
func executeTemplate(wr io.Writer, name string, data interface{}) error {
|
// ExecuteTemplate applies the template with name to the specified data object,
|
||||||
|
// writing the output to wr.
|
||||||
|
// A template will be executed safely in parallel.
|
||||||
|
func ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
|
||||||
if BConfig.RunMode == DEV {
|
if BConfig.RunMode == DEV {
|
||||||
templatesLock.RLock()
|
templatesLock.RLock()
|
||||||
defer templatesLock.RUnlock()
|
defer templatesLock.RUnlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user