wip
This commit is contained in:
@@ -4,6 +4,9 @@ package registry
|
||||
import (
|
||||
"embed"
|
||||
"io"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed templates/*.marka
|
||||
@@ -23,3 +26,20 @@ func GetTemplate(name string) (string, error) {
|
||||
|
||||
return string(templateBytes), nil
|
||||
}
|
||||
|
||||
func ListTemplates() ([]string, error) {
|
||||
var templateNames []string
|
||||
err := fs.WalkDir(templates, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !d.IsDir() && strings.HasSuffix(path, ".marka") {
|
||||
templateNames = append(templateNames, strings.TrimSuffix(filepath.Base(path), ".marka"))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return templateNames, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user