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
4c0c0ec2
Commit
4c0c0ec2
authored
Jan 07, 2016
by
ysqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TplNames renamed TplName ,fix #1229,Remember modify bee tool.
parent
80912b62
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
24 deletions
+24
-24
controller.go
controller.go
+14
-14
namespace_test.go
namespace_test.go
+6
-6
README.md
utils/captcha/README.md
+2
-2
captcha.go
utils/captcha/captcha.go
+2
-2
No files found.
controller.go
View file @
4c0c0ec2
...
@@ -68,7 +68,7 @@ type Controller struct {
...
@@ -68,7 +68,7 @@ type Controller struct {
AppController
interface
{}
AppController
interface
{}
// template data
// template data
TplName
s
string
TplName
string
Layout
string
Layout
string
LayoutSections
map
[
string
]
string
// the key is the section name and the value is the template name
LayoutSections
map
[
string
]
string
// the key is the section name and the value is the template name
TplExt
string
TplExt
string
...
@@ -105,7 +105,7 @@ type ControllerInterface interface {
...
@@ -105,7 +105,7 @@ type ControllerInterface interface {
// Init generates default values of controller operations.
// Init generates default values of controller operations.
func
(
c
*
Controller
)
Init
(
ctx
*
context
.
Context
,
controllerName
,
actionName
string
,
app
interface
{})
{
func
(
c
*
Controller
)
Init
(
ctx
*
context
.
Context
,
controllerName
,
actionName
string
,
app
interface
{})
{
c
.
Layout
=
""
c
.
Layout
=
""
c
.
TplName
s
=
""
c
.
TplName
=
""
c
.
controllerName
=
controllerName
c
.
controllerName
=
controllerName
c
.
actionName
=
actionName
c
.
actionName
=
actionName
c
.
Ctx
=
ctx
c
.
Ctx
=
ctx
...
@@ -200,12 +200,12 @@ func (c *Controller) RenderBytes() ([]byte, error) {
...
@@ -200,12 +200,12 @@ 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
//if the controller has set layout, then first get the tplname's content set the content to the layout
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
if
c
.
Layout
!=
""
{
if
c
.
Layout
!=
""
{
if
c
.
TplName
s
==
""
{
if
c
.
TplName
==
""
{
c
.
TplName
s
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
c
.
TplName
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
}
}
if
BConfig
.
RunMode
==
DEV
{
if
BConfig
.
RunMode
==
DEV
{
buildFiles
:=
[]
string
{
c
.
TplName
s
}
buildFiles
:=
[]
string
{
c
.
TplName
}
if
c
.
LayoutSections
!=
nil
{
if
c
.
LayoutSections
!=
nil
{
for
_
,
sectionTpl
:=
range
c
.
LayoutSections
{
for
_
,
sectionTpl
:=
range
c
.
LayoutSections
{
if
sectionTpl
==
""
{
if
sectionTpl
==
""
{
...
@@ -216,10 +216,10 @@ func (c *Controller) RenderBytes() ([]byte, error) {
...
@@ -216,10 +216,10 @@ func (c *Controller) RenderBytes() ([]byte, error) {
}
}
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
buildFiles
...
)
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
buildFiles
...
)
}
}
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
s
];
!
ok
{
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
];
!
ok
{
panic
(
"can't find templatefile in the path:"
+
c
.
TplName
s
)
panic
(
"can't find templatefile in the path:"
+
c
.
TplName
)
}
}
err
:=
BeeTemplates
[
c
.
TplName
s
]
.
ExecuteTemplate
(
&
buf
,
c
.
TplNames
,
c
.
Data
)
err
:=
BeeTemplates
[
c
.
TplName
]
.
ExecuteTemplate
(
&
buf
,
c
.
TplName
,
c
.
Data
)
if
err
!=
nil
{
if
err
!=
nil
{
Trace
(
"template Execute err:"
,
err
)
Trace
(
"template Execute err:"
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -252,17 +252,17 @@ func (c *Controller) RenderBytes() ([]byte, error) {
...
@@ -252,17 +252,17 @@ func (c *Controller) RenderBytes() ([]byte, error) {
return
buf
.
Bytes
(),
nil
return
buf
.
Bytes
(),
nil
}
}
if
c
.
TplName
s
==
""
{
if
c
.
TplName
==
""
{
c
.
TplName
s
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
c
.
TplName
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
}
}
if
BConfig
.
RunMode
==
DEV
{
if
BConfig
.
RunMode
==
DEV
{
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
c
.
TplName
s
)
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
c
.
TplName
)
}
}
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
s
];
!
ok
{
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
];
!
ok
{
panic
(
"can't find templatefile in the path:"
+
c
.
TplName
s
)
panic
(
"can't find templatefile in the path:"
+
c
.
TplName
)
}
}
buf
.
Reset
()
buf
.
Reset
()
err
:=
BeeTemplates
[
c
.
TplName
s
]
.
ExecuteTemplate
(
&
buf
,
c
.
TplNames
,
c
.
Data
)
err
:=
BeeTemplates
[
c
.
TplName
]
.
ExecuteTemplate
(
&
buf
,
c
.
TplName
,
c
.
Data
)
if
err
!=
nil
{
if
err
!=
nil
{
Trace
(
"template Execute err:"
,
err
)
Trace
(
"template Execute err:"
,
err
)
return
nil
,
err
return
nil
,
err
...
...
namespace_test.go
View file @
4c0c0ec2
...
@@ -61,8 +61,8 @@ func TestNamespaceNest(t *testing.T) {
...
@@ -61,8 +61,8 @@ func TestNamespaceNest(t *testing.T) {
ns
.
Namespace
(
ns
.
Namespace
(
NewNamespace
(
"/admin"
)
.
NewNamespace
(
"/admin"
)
.
Get
(
"/order"
,
func
(
ctx
*
context
.
Context
)
{
Get
(
"/order"
,
func
(
ctx
*
context
.
Context
)
{
ctx
.
Output
.
Body
([]
byte
(
"order"
))
ctx
.
Output
.
Body
([]
byte
(
"order"
))
}),
}),
)
)
AddNamespace
(
ns
)
AddNamespace
(
ns
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
...
@@ -79,8 +79,8 @@ func TestNamespaceNestParam(t *testing.T) {
...
@@ -79,8 +79,8 @@ func TestNamespaceNestParam(t *testing.T) {
ns
.
Namespace
(
ns
.
Namespace
(
NewNamespace
(
"/admin"
)
.
NewNamespace
(
"/admin"
)
.
Get
(
"/order/:id"
,
func
(
ctx
*
context
.
Context
)
{
Get
(
"/order/:id"
,
func
(
ctx
*
context
.
Context
)
{
ctx
.
Output
.
Body
([]
byte
(
ctx
.
Input
.
Param
(
":id"
)))
ctx
.
Output
.
Body
([]
byte
(
ctx
.
Input
.
Param
(
":id"
)))
}),
}),
)
)
AddNamespace
(
ns
)
AddNamespace
(
ns
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
...
@@ -124,8 +124,8 @@ func TestNamespaceFilter(t *testing.T) {
...
@@ -124,8 +124,8 @@ func TestNamespaceFilter(t *testing.T) {
ctx
.
Output
.
Body
([]
byte
(
"this is Filter"
))
ctx
.
Output
.
Body
([]
byte
(
"this is Filter"
))
})
.
})
.
Get
(
"/user/:id"
,
func
(
ctx
*
context
.
Context
)
{
Get
(
"/user/:id"
,
func
(
ctx
*
context
.
Context
)
{
ctx
.
Output
.
Body
([]
byte
(
ctx
.
Input
.
Param
(
":id"
)))
ctx
.
Output
.
Body
([]
byte
(
ctx
.
Input
.
Param
(
":id"
)))
})
})
AddNamespace
(
ns
)
AddNamespace
(
ns
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
if
w
.
Body
.
String
()
!=
"this is Filter"
{
if
w
.
Body
.
String
()
!=
"this is Filter"
{
...
...
utils/captcha/README.md
View file @
4c0c0ec2
...
@@ -24,11 +24,11 @@ type MainController struct {
...
@@ -24,11 +24,11 @@ type MainController struct {
}
}
func (this *MainController) Get() {
func (this *MainController) Get() {
this.TplName
s
= "index.tpl"
this.TplName = "index.tpl"
}
}
func (this *MainController) Post() {
func (this *MainController) Post() {
this.TplName
s
= "index.tpl"
this.TplName = "index.tpl"
this.Data["Success"] = cpt.VerifyReq(this.Ctx.Request)
this.Data["Success"] = cpt.VerifyReq(this.Ctx.Request)
}
}
...
...
utils/captcha/captcha.go
View file @
4c0c0ec2
...
@@ -37,11 +37,11 @@
...
@@ -37,11 +37,11 @@
// }
// }
//
//
// func (this *MainController) Get() {
// func (this *MainController) Get() {
// this.TplName
s
= "index.tpl"
// this.TplName = "index.tpl"
// }
// }
//
//
// func (this *MainController) Post() {
// func (this *MainController) Post() {
// this.TplName
s
= "index.tpl"
// this.TplName = "index.tpl"
//
//
// this.Data["Success"] = cpt.VerifyReq(this.Ctx.Request)
// this.Data["Success"] = cpt.VerifyReq(this.Ctx.Request)
// }
// }
...
...
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