@@ -22,6 +22,7 @@ type bindings struct {
2222// bind stores the given `value` and returns a placeholder parameter.
2323func (b * bindings ) bind (value interface {}) string {
2424 b .values = append (b .values , value )
25+
2526 return "?"
2627}
2728
@@ -45,7 +46,7 @@ func (r *repository) addFunctions(functions template.FuncMap) {
4546 }
4647}
4748
48- // add walks a filesystem and parses the corresponding templates
49+ // add walks a filesystem and parses the corresponding templates.
4950func (r * repository ) add (namespace string , filesystem fs.FS , extension string ) (err error ) {
5051 filesInFilesystem , err := getFilesInFilesystem (filesystem , extension )
5152 if err != nil {
@@ -82,6 +83,7 @@ func (r *repository) parse(namespace string, name string, data interface{}) (str
8283
8384 // Apply the bind function which stores the values for any placeholder parameters
8485 values := & bindings {values : []interface {}{}}
86+
8587 clonedTmpl .Funcs (template.FuncMap {"bind" : values .bind })
8688
8789 var b bytes.Buffer
@@ -92,7 +94,7 @@ func (r *repository) parse(namespace string, name string, data interface{}) (str
9294 return b .String (), values .values , nil
9395}
9496
95- // bind is a dummy function which is never used while executing a template
97+ // bind is a dummy function which is never used while executing a template.
9698func bind (param interface {}) string {
9799 return "?"
98100}
@@ -108,7 +110,6 @@ func getFilesInFilesystem(filesystem fs.FS, extension string) ([]string, error)
108110
109111 return nil
110112 })
111-
112113 if err != nil {
113114 return nil , fmt .Errorf ("unable to retrieve files in directory %w" , err )
114115 }
0 commit comments