NewView returns a new view by parsing the given layout and files
(app *app.App, viewConfig Config, files ...string)
| 59 | |
| 60 | // NewView returns a new view by parsing the given layout and files |
| 61 | func (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. |
no test coverage detected