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
284dfc08
Commit
284dfc08
authored
Sep 07, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move the template related fun to template.go
parent
85d8ec5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
29 deletions
+29
-29
beego.go
beego.go
+0
-27
template.go
template.go
+29
-2
No files found.
beego.go
View file @
284dfc08
...
...
@@ -100,30 +100,3 @@ func initBeforeHttpRun() {
}
}
}
// SetViewsPath sets view directory path in beego application.
func
SetViewsPath
(
path
string
)
*
App
{
ViewsPath
=
path
return
BeeApp
}
// SetStaticPath sets static directory path and proper url pattern in beego application.
// if beego.SetStaticPath("static","public"), visit /static/* to load static file in folder "public".
func
SetStaticPath
(
url
string
,
path
string
)
*
App
{
if
!
strings
.
HasPrefix
(
url
,
"/"
)
{
url
=
"/"
+
url
}
url
=
strings
.
TrimRight
(
url
,
"/"
)
StaticDir
[
url
]
=
path
return
BeeApp
}
// DelStaticPath removes the static folder setting in this url pattern in beego application.
func
DelStaticPath
(
url
string
)
*
App
{
if
!
strings
.
HasPrefix
(
url
,
"/"
)
{
url
=
"/"
+
url
}
url
=
strings
.
TrimRight
(
url
,
"/"
)
delete
(
StaticDir
,
url
)
return
BeeApp
}
template.go
View file @
284dfc08
...
...
@@ -128,7 +128,7 @@ func AddTemplateExt(ext string) {
// build all template files in a directory.
// it makes beego can render any template file in view directory.
func
BuildTemplate
(
dir
string
,
files
...
string
)
error
{
func
BuildTemplate
(
dir
string
,
files
...
string
)
error
{
if
_
,
err
:=
os
.
Stat
(
dir
);
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
return
nil
...
...
@@ -149,7 +149,7 @@ func BuildTemplate(dir string, files... string) error {
}
for
_
,
v
:=
range
self
.
files
{
for
_
,
file
:=
range
v
{
if
(
len
(
files
)
==
0
||
utils
.
InSlice
(
file
,
files
)
)
{
if
len
(
files
)
==
0
||
utils
.
InSlice
(
file
,
files
)
{
t
,
err
:=
getTemplate
(
self
.
root
,
file
,
v
...
)
if
err
!=
nil
{
Trace
(
"parse template err:"
,
file
,
err
)
...
...
@@ -263,3 +263,30 @@ func _getTemplate(t0 *template.Template, root string, submods [][]string, others
}
return
}
// SetViewsPath sets view directory path in beego application.
func
SetViewsPath
(
path
string
)
*
App
{
ViewsPath
=
path
return
BeeApp
}
// SetStaticPath sets static directory path and proper url pattern in beego application.
// if beego.SetStaticPath("static","public"), visit /static/* to load static file in folder "public".
func
SetStaticPath
(
url
string
,
path
string
)
*
App
{
if
!
strings
.
HasPrefix
(
url
,
"/"
)
{
url
=
"/"
+
url
}
url
=
strings
.
TrimRight
(
url
,
"/"
)
StaticDir
[
url
]
=
path
return
BeeApp
}
// DelStaticPath removes the static folder setting in this url pattern in beego application.
func
DelStaticPath
(
url
string
)
*
App
{
if
!
strings
.
HasPrefix
(
url
,
"/"
)
{
url
=
"/"
+
url
}
url
=
strings
.
TrimRight
(
url
,
"/"
)
delete
(
StaticDir
,
url
)
return
BeeApp
}
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