feat(Get): adds 'require' template func

This commit is contained in:
Lewis Wynne 2025-11-19 22:49:00 +00:00
parent 73cea8d660
commit 0a70169adb

View file

@ -121,6 +121,13 @@ func applyTemplate(tplBytes []byte, substitutions []string) ([]byte, error) {
vars[key] = val vars[key] = val
} }
funcMap := template.FuncMap{ funcMap := template.FuncMap{
"require": func(v any) (string, error) {
s := fmt.Sprint(v)
if s == "" {
return "", fmt.Errorf("required value is missing or empty")
}
return s, nil
},
"default": func(def string, v any) string { "default": func(def string, v any) string {
s := fmt.Sprint(v) s := fmt.Sprint(v)
if s == "" { if s == "" {