MCPcopy Index your code
hub / github.com/dnote/dnote / NewView

Method NewView

pkg/server/views/engine.go:61–78  ·  view source on GitHub ↗

NewView returns a new view by parsing the given layout and files

(app *app.App, viewConfig Config, files ...string)

Source from the content-addressed store, hash-verified

59
60// NewView returns a new view by parsing the given layout and files
61func (e Engine) NewView(app *app.App, viewConfig Config, files ...string) *View {
62 viewHelpers := initHelpers(viewConfig, app)
63 t := template.New(viewConfig.Title).Funcs(viewHelpers)
64
65 targetFiles := e.getTargetFiles(files)
66
67 t, err := t.ParseFS(e.fileSystem, targetFiles...)
68 if err != nil {
69 panic(errors.Wrap(err, "instantiating view"))
70 }
71
72 return &View{
73 Template: t,
74 Layout: viewConfig.getLayout(),
75 AlertInBody: viewConfig.AlertInBody,
76 App: app,
77 }
78}
79
80// layoutFiles returns a slice of strings representing
81// the layout files used in our application.

Callers 2

NewUsersFunction · 0.80
NewStaticFunction · 0.80

Calls 4

getTargetFilesMethod · 0.95
initHelpersFunction · 0.85
NewMethod · 0.80
getLayoutMethod · 0.80

Tested by

no test coverage detected