Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
0f982c4a
authored
2013-04-02 23:57:15 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add Config.Int64 and Template add Runmode==dev everytime parsefile
1 parent
f78ceb82
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
config.go
controller.go
config.go
View file @
0f982c4
...
...
@@ -97,6 +97,10 @@ func (c *Config) Int(key string) (int, error) {
return
strconv
.
Atoi
(
c
.
data
[
key
])
}
func
(
c
*
Config
)
Int64
(
key
string
)
(
int64
,
error
)
{
return
strconv
.
ParseInt
(
c
.
data
[
key
],
10
,
64
)
}
// Float returns the float value for a given key.
func
(
c
*
Config
)
Float
(
key
string
)
(
float64
,
error
)
{
return
strconv
.
ParseFloat
(
c
.
data
[
key
],
64
)
...
...
controller.go
View file @
0f982c4
...
...
@@ -98,19 +98,30 @@ func (c *Controller) Render() error {
func
(
c
*
Controller
)
RenderBytes
()
([]
byte
,
error
)
{
//if the controller has set layout, then first get the tplname's content set the content to the layout
var
t
*
template
.
Template
var
err
error
if
c
.
Layout
!=
""
{
if
c
.
TplNames
==
""
{
c
.
TplNames
=
c
.
ChildName
+
"/"
+
c
.
Ctx
.
Request
.
Method
+
"."
+
c
.
TplExt
}
if
RunMode
==
"dev"
{
t
,
err
=
template
.
New
(
"beegoTemplate"
)
.
Funcs
(
beegoTplFuncMap
)
.
ParseFiles
(
path
.
Join
(
ViewsPath
,
c
.
TplNames
),
path
.
Join
(
ViewsPath
,
c
.
Layout
))
if
err
!=
nil
{
Trace
(
"template ParseFiles err:"
,
err
)
}
}
else
{
subdir
:=
path
.
Dir
(
c
.
TplNames
)
t
=
BeeTemplates
[
subdir
]
}
_
,
file
:=
path
.
Split
(
c
.
TplNames
)
subdir
:=
path
.
Dir
(
c
.
TplNames
)
newbytes
:=
bytes
.
NewBufferString
(
""
)
BeeTemplates
[
subdir
]
.
ExecuteTemplate
(
newbytes
,
file
,
c
.
Data
)
t
.
ExecuteTemplate
(
newbytes
,
file
,
c
.
Data
)
tplcontent
,
_
:=
ioutil
.
ReadAll
(
newbytes
)
c
.
Data
[
"LayoutContent"
]
=
template
.
HTML
(
string
(
tplcontent
))
_
,
file
=
path
.
Split
(
c
.
Layout
)
ibytes
:=
bytes
.
NewBufferString
(
""
)
err
:=
BeeTemplates
[
subdir
]
.
ExecuteTemplate
(
ibytes
,
file
,
c
.
Data
)
err
:=
t
.
ExecuteTemplate
(
ibytes
,
file
,
c
.
Data
)
if
err
!=
nil
{
Trace
(
"template Execute err:"
,
err
)
}
...
...
@@ -120,10 +131,18 @@ func (c *Controller) RenderBytes() ([]byte, error) {
if
c
.
TplNames
==
""
{
c
.
TplNames
=
c
.
ChildName
+
"/"
+
c
.
Ctx
.
Request
.
Method
+
"."
+
c
.
TplExt
}
if
RunMode
==
"dev"
{
t
,
err
=
template
.
New
(
"beegoTemplate"
)
.
Funcs
(
beegoTplFuncMap
)
.
ParseFiles
(
path
.
Join
(
ViewsPath
,
c
.
TplNames
))
if
err
!=
nil
{
Trace
(
"template ParseFiles err:"
,
err
)
}
}
else
{
subdir
:=
path
.
Dir
(
c
.
TplNames
)
t
=
BeeTemplates
[
subdir
]
}
_
,
file
:=
path
.
Split
(
c
.
TplNames
)
subdir
:=
path
.
Dir
(
c
.
TplNames
)
ibytes
:=
bytes
.
NewBufferString
(
""
)
err
:=
BeeTemplates
[
subdir
]
.
ExecuteTemplate
(
ibytes
,
file
,
c
.
Data
)
err
:=
t
.
ExecuteTemplate
(
ibytes
,
file
,
c
.
Data
)
if
err
!=
nil
{
Trace
(
"template Execute err:"
,
err
)
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment