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
62188a37
Commit
62188a37
authored
Dec 24, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/astaxie/beego
parents
0b659961
37aa2dc1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
controller.go
controller.go
+20
-0
No files found.
controller.go
View file @
62188a37
...
...
@@ -38,6 +38,7 @@ type Controller struct {
actionName
string
TplNames
string
Layout
string
LayoutSections
map
[
string
]
string
// the key is the section name and the value is the template name
TplExt
string
_xsrf_token
string
gotofunc
string
...
...
@@ -161,6 +162,25 @@ func (c *Controller) RenderBytes() ([]byte, error) {
}
tplcontent
,
_
:=
ioutil
.
ReadAll
(
newbytes
)
c
.
Data
[
"LayoutContent"
]
=
template
.
HTML
(
string
(
tplcontent
))
if
c
.
LayoutSections
!=
nil
{
for
sectionName
,
sectionTpl
:=
range
c
.
LayoutSections
{
if
(
sectionTpl
==
""
)
{
c
.
Data
[
sectionName
]
=
""
continue
}
sectionBytes
:=
bytes
.
NewBufferString
(
""
)
err
=
BeeTemplates
[
sectionTpl
]
.
ExecuteTemplate
(
sectionBytes
,
sectionTpl
,
c
.
Data
)
if
err
!=
nil
{
Trace
(
"template Execute err:"
,
err
)
return
nil
,
err
}
sectionContent
,
_
:=
ioutil
.
ReadAll
(
sectionBytes
)
c
.
Data
[
sectionName
]
=
template
.
HTML
(
string
(
sectionContent
))
}
}
ibytes
:=
bytes
.
NewBufferString
(
""
)
err
=
BeeTemplates
[
c
.
Layout
]
.
ExecuteTemplate
(
ibytes
,
c
.
Layout
,
c
.
Data
)
if
err
!=
nil
{
...
...
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