MCPcopy
hub / github.com/livebud/bud / loadView

Method loadView

framework/controller/loader.go:253–279  ·  view source on GitHub ↗
(controllerKey, actionKey, actionRoute string)

Source from the content-addressed store, hash-verified

251}
252
253func (l *loader) loadView(controllerKey, actionKey, actionRoute string) *View {
254 viewDir := path.Join("view", controllerKey)
255 des, err := fs.ReadDir(l.fsys, viewDir)
256 if err != nil {
257 if errors.Is(err, fs.ErrNotExist) {
258 return nil
259 }
260 l.Bail(fmt.Errorf("controller: unable read view directory %q . %w", viewDir, err))
261 }
262 for _, de := range des {
263 name := de.Name()
264 ext := path.Ext(name)
265 if ext != ".svelte" {
266 continue
267 }
268 base := strings.TrimSuffix(path.Base(name), ext)
269 key := path.Base(actionKey)
270 if base != key {
271 continue
272 }
273 l.imports.Add(l.module.Import("bud/internal/web/view"))
274 return &View{
275 Route: actionRoute,
276 }
277 }
278 return nil
279}
280
281func (l *loader) loadActionParams(params []*parser.Param) (inputs []*ActionParam) {
282 numParams := len(params)

Callers 1

loadActionMethod · 0.95

Calls 7

IsMethod · 0.80
BailMethod · 0.80
NameMethod · 0.65
AddMethod · 0.65
ReadDirMethod · 0.45
ExtMethod · 0.45
ImportMethod · 0.45

Tested by

no test coverage detected