feat(Get): adds 'require' template func
This commit is contained in:
parent
73cea8d660
commit
0a70169adb
1 changed files with 7 additions and 0 deletions
|
|
@ -121,6 +121,13 @@ func applyTemplate(tplBytes []byte, substitutions []string) ([]byte, error) {
|
|||
vars[key] = val
|
||||
}
|
||||
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 {
|
||||
s := fmt.Sprint(v)
|
||||
if s == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue