-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
60 lines (52 loc) · 1.37 KB
/
Copy pathconfig.go
File metadata and controls
60 lines (52 loc) · 1.37 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package pbj
import "fmt"
// Generic mount function for "routers"
func Mount(fn func(*App)) func(*App) { return fn }
// WithMeta will include <meta name content> tag
func WithMeta(name, content string) func(*App) {
return func(app *App) {
app.headerContent = fmt.Sprintf(
`%s<meta name="%s" content="%s">`,
app.headerContent, name, content,
)
}
}
// WithStylesheet will include <link rel="stylesheet" href> tag
func WithStylesheet(href string) func(*App) {
return func(app *App) {
app.headerContent = fmt.Sprintf(
`%s<link rel="stylesheet" href="%s" />`,
app.headerContent, href,
)
}
}
// WithScript will include <script src></script> tag
func WithScript(src string) func(*App) {
return func(app *App) {
app.headerContent = fmt.Sprintf(
`%s<script src="%s"></script>`,
app.headerContent, src,
)
}
}
// WithInlineScript will include <script></script> tag
func WithInlineScript(content string) func(*App) {
return func(app *App) {
app.headerContent = fmt.Sprintf(
`%s<script>%s</script>`,
app.headerContent, content,
)
}
}
// WithPublicAccess configures the Page to be public accessable
func WithPublicAccess(public bool) func(*Page) {
return func(p *Page) {
p.public = public
}
}
// WithAdminOnlyAccess configures the Page to only allow admin access
func WithAdminOnlyAccess(admin bool) func(*Page) {
return func(p *Page) {
p.admin = admin
}
}