Skip to content

Commit

Permalink
layout: fix relative paths for New
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Sep 22, 2024
1 parent cc61a96 commit 4d98111
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion layout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ type (

// New parses the given layout file.
func New(path string, funcs ...template.FuncMap) (*Layout, error) {
return NewFromFS(os.DirFS("."), path, funcs...)
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
return rawNew(data, funcs...)
}

// NewFromFS parses the layout from the given fs.FS. It allows to read layout
Expand All @@ -80,7 +84,10 @@ func NewFromFS(fsys fs.FS, path string, funcs ...template.FuncMap) (*Layout, err
if err != nil {
return nil, err
}
return rawNew(data, funcs...)
}

func rawNew(data []byte, funcs ...template.FuncMap) (*Layout, error) {
lt := Layout{
ctxs: make(map[tele.Context]string),
funcs: make(template.FuncMap),
Expand Down

0 comments on commit 4d98111

Please sign in to comment.