forked from ungerik/go-start
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_0.go
38 lines (35 loc) · 917 Bytes
/
user_0.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package subpage
import (
. "github.com/ungerik/go-start/view"
"github.com/ungerik/go-start/examples/ViewPaths/views"
"github.com/ungerik/go-start/examples/ViewPaths/views/root"
)
func init() {
views.Admin_User0 = &Page{
Title: RenderView(
func(ctx *Context) error {
// The username is in ctx.URLArgs[0]
ctx.Response.WriteString("Manage " + ctx.URLArgs[0])
return nil
},
),
Content: Views{
DynamicViewBindURLArgs(
// The URL argument 0 can also be bound dynamically
// to a function argument:
func(ctx *Context, username string) (View, error) {
return H1("Manage user ", username), nil
},
),
root.Navigation(),
DynamicViewBindURLArgs(
func(ctx *Context, username string) (View, error) {
return Views{
H4(Printf("This view uses the URL argument '%s':", username)),
HTML(views.Admin_User0.URL(ctx)),
}, nil
},
),
},
}
}