Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
ebdf4412
Commit
ebdf4412
authored
Apr 01, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1848 from JessonChan/template_fix
make template execution be expected
parents
fe4fa6a0
8ec6dd93
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
controller.go
controller.go
+3
-3
template.go
template.go
+4
-1
No files found.
controller.go
View file @
ebdf4412
...
@@ -208,7 +208,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
...
@@ -208,7 +208,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
continue
continue
}
}
buf
.
Reset
()
buf
.
Reset
()
err
=
e
xecuteTemplate
(
&
buf
,
sectionTpl
,
c
.
Data
)
err
=
E
xecuteTemplate
(
&
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) {
...
@@ -217,7 +217,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
}
}
buf
.
Reset
()
buf
.
Reset
()
e
xecuteTemplate
(
&
buf
,
c
.
Layout
,
c
.
Data
)
E
xecuteTemplate
(
&
buf
,
c
.
Layout
,
c
.
Data
)
}
}
return
buf
.
Bytes
(),
err
return
buf
.
Bytes
(),
err
}
}
...
@@ -242,7 +242,7 @@ func (c *Controller) renderTemplate() (bytes.Buffer, error) {
...
@@ -242,7 +242,7 @@ func (c *Controller) renderTemplate() (bytes.Buffer, error) {
}
}
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
buildFiles
...
)
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
buildFiles
...
)
}
}
return
buf
,
e
xecuteTemplate
(
&
buf
,
c
.
TplName
,
c
.
Data
)
return
buf
,
E
xecuteTemplate
(
&
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.
...
...
template.go
View file @
ebdf4412
...
@@ -41,7 +41,10 @@ var (
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment