This commit is contained in:
Max Richter
2025-09-25 17:28:59 +02:00
parent b13d5015f4
commit 96e7f72d1f
13 changed files with 336 additions and 123 deletions

View File

@@ -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
}