MCPcopy Create free account
hub / github.com/dnote/dnote / initHelpers

Function initHelpers

pkg/server/views/helpers.go:30–62  ·  view source on GitHub ↗
(c Config, a *app.App)

Source from the content-addressed store, hash-verified

28)
29
30func initHelpers(c Config, a *app.App) template.FuncMap {
31 ctx := newViewCtx(c)
32
33 ret := template.FuncMap{
34 "csrfField": ctx.csrfField,
35 "css": ctx.css,
36 "js": ctx.js,
37 "title": ctx.title,
38 "headerTemplate": ctx.headerTemplate,
39 "rootURL": ctx.rootURL,
40 "getFullMonthName": ctx.getFullMonthName,
41 "toDateTime": ctx.toDateTime,
42 "excerpt": ctx.excerpt,
43 "timeAgo": ctx.timeAgo,
44 "timeFormat": ctx.timeFormat,
45 "toISOString": ctx.toISOString,
46 "dict": ctx.dict,
47 "defaultValue": ctx.defaultValue,
48 "add": ctx.add,
49 "assetBaseURL": func() string {
50 return a.AssetBaseURL
51 },
52 }
53
54 // extend with helpers that are defined specific to a view
55 if c.HelperFuncs != nil {
56 for k, v := range c.HelperFuncs {
57 ret[k] = v
58 }
59 }
60
61 return ret
62}
63
64func (v viewCtx) csrfField() (template.HTML, error) {
65 return "", errors.New("csrfField is not implemented")

Callers 1

NewViewMethod · 0.85

Calls 1

newViewCtxFunction · 0.85

Tested by

no test coverage detected