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
43454406
Commit
43454406
authored
Jan 07, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1540 from ysqi/develop
TplNames renamed TplName ,fix #1229,Remember modify bee tool.
parents
ecc6bcba
4c0c0ec2
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 @
43454406
...
...
@@ -68,7 +68,7 @@ type Controller struct {
AppController
interface
{}
// template data
TplName
s
string
TplName
string
Layout
string
LayoutSections
map
[
string
]
string
// the key is the section name and the value is the template name
TplExt
string
...
...
@@ -105,7 +105,7 @@ type ControllerInterface interface {
// Init generates default values of controller operations.
func
(
c
*
Controller
)
Init
(
ctx
*
context
.
Context
,
controllerName
,
actionName
string
,
app
interface
{})
{
c
.
Layout
=
""
c
.
TplName
s
=
""
c
.
TplName
=
""
c
.
controllerName
=
controllerName
c
.
actionName
=
actionName
c
.
Ctx
=
ctx
...
...
@@ -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
var
buf
bytes
.
Buffer
if
c
.
Layout
!=
""
{
if
c
.
TplName
s
==
""
{
c
.
TplName
s
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
if
c
.
TplName
==
""
{
c
.
TplName
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
}
if
BConfig
.
RunMode
==
DEV
{
buildFiles
:=
[]
string
{
c
.
TplName
s
}
buildFiles
:=
[]
string
{
c
.
TplName
}
if
c
.
LayoutSections
!=
nil
{
for
_
,
sectionTpl
:=
range
c
.
LayoutSections
{
if
sectionTpl
==
""
{
...
...
@@ -216,10 +216,10 @@ func (c *Controller) RenderBytes() ([]byte, error) {
}
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
buildFiles
...
)
}
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
s
];
!
ok
{
panic
(
"can't find templatefile in the path:"
+
c
.
TplName
s
)
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
];
!
ok
{
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
{
Trace
(
"template Execute err:"
,
err
)
return
nil
,
err
...
...
@@ -252,17 +252,17 @@ func (c *Controller) RenderBytes() ([]byte, error) {
return
buf
.
Bytes
(),
nil
}
if
c
.
TplName
s
==
""
{
c
.
TplName
s
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
if
c
.
TplName
==
""
{
c
.
TplName
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
}
if
BConfig
.
RunMode
==
DEV
{
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
c
.
TplName
s
)
BuildTemplate
(
BConfig
.
WebConfig
.
ViewsPath
,
c
.
TplName
)
}
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
s
];
!
ok
{
panic
(
"can't find templatefile in the path:"
+
c
.
TplName
s
)
if
_
,
ok
:=
BeeTemplates
[
c
.
TplName
];
!
ok
{
panic
(
"can't find templatefile in the path:"
+
c
.
TplName
)
}
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
{
Trace
(
"template Execute err:"
,
err
)
return
nil
,
err
...
...
namespace_test.go
View file @
43454406
...
...
@@ -61,8 +61,8 @@ func TestNamespaceNest(t *testing.T) {
ns
.
Namespace
(
NewNamespace
(
"/admin"
)
.
Get
(
"/order"
,
func
(
ctx
*
context
.
Context
)
{
ctx
.
Output
.
Body
([]
byte
(
"order"
))
}),
ctx
.
Output
.
Body
([]
byte
(
"order"
))
}),
)
AddNamespace
(
ns
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
...
...
@@ -79,8 +79,8 @@ func TestNamespaceNestParam(t *testing.T) {
ns
.
Namespace
(
NewNamespace
(
"/admin"
)
.
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
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
...
...
@@ -124,8 +124,8 @@ func TestNamespaceFilter(t *testing.T) {
ctx
.
Output
.
Body
([]
byte
(
"this is Filter"
))
})
.
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
)
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
if
w
.
Body
.
String
()
!=
"this is Filter"
{
...
...
utils/captcha/README.md
View file @
43454406
...
...
@@ -24,11 +24,11 @@ type MainController struct {
}
func (this *MainController) Get() {
this.TplName
s
= "index.tpl"
this.TplName = "index.tpl"
}
func (this *MainController) Post() {
this.TplName
s
= "index.tpl"
this.TplName = "index.tpl"
this.Data["Success"] = cpt.VerifyReq(this.Ctx.Request)
}
...
...
utils/captcha/captcha.go
View file @
43454406
...
...
@@ -37,11 +37,11 @@
// }
//
// func (this *MainController) Get() {
// this.TplName
s
= "index.tpl"
// this.TplName = "index.tpl"
// }
//
// func (this *MainController) Post() {
// this.TplName
s
= "index.tpl"
// this.TplName = "index.tpl"
//
// 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