Skip to content

Commit

Permalink
Fix subst syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorlin committed Mar 23, 2024
1 parent 1f14046 commit 9ddd71d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/module/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ func PrepareModule(module data.ModuleConfig) (string, error) {
}

func subst(format string, jsonEncodedInputs ...string) string {

jsonDecodedInputs := make([]any, 0, len(jsonEncodedInputs))
jsonDecodedInputs := make([]interface{}, 0, len(jsonEncodedInputs))

for _, input := range jsonEncodedInputs {
var s string
Expand All @@ -202,7 +201,7 @@ func subst(format string, jsonEncodedInputs ...string) string {

jsonDecodedInputs = append(jsonDecodedInputs, s)
}
log.Printf("jsonDecodedInputs:%v", jsonDecodedInputs)
log.Printf("jsonDecodedInputs: %v", jsonDecodedInputs)

return fmt.Sprintf(format, jsonDecodedInputs...)
}
Expand All @@ -218,12 +217,12 @@ func LoadModule(module data.ModuleConfig, inputs map[string]string) (*data.Modul
// TODO: golang handlebars implementation, with shortcode for string encoding e.g. escape_string

templateName := fmt.Sprintf("%s-%s-%s", module.Repo, module.Path, module.Hash)
tmpl, err := template.New(templateName).Parse(moduleText)
tmpl.Funcs(template.FuncMap{
tmpl := template.New(templateName).Funcs(template.FuncMap{
"subst": subst,
})
tmpl, err = tmpl.Parse(moduleText)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to parse template: %v", err)
}

newInputs := make(map[string]string)
Expand Down

1 comment on commit 9ddd71d

@noryev
Copy link
Contributor

@noryev noryev commented on 9ddd71d Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀👀👀

Please sign in to comment.