File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -283,9 +283,8 @@ func trimSuffix(suffix, s string) string {
283
283
return strings .TrimSuffix (s , suffix )
284
284
}
285
285
286
- func generateFile (config Config , containers Context ) bool {
287
- templatePath := config .Template
288
- tmpl , err := template .New (filepath .Base (templatePath )).Funcs (template.FuncMap {
286
+ func newTemplate (name string ) * template.Template {
287
+ tmpl := template .New (name ).Funcs (template.FuncMap {
289
288
"closest" : arrayClosest ,
290
289
"coalesce" : coalesce ,
291
290
"contains" : contains ,
@@ -312,7 +311,13 @@ func generateFile(config Config, containers Context) bool {
312
311
"whereNotExist" : whereNotExist ,
313
312
"whereAny" : whereAny ,
314
313
"whereAll" : whereAll ,
315
- }).ParseFiles (templatePath )
314
+ })
315
+ return tmpl
316
+ }
317
+
318
+ func generateFile (config Config , containers Context ) bool {
319
+ templatePath := config .Template
320
+ tmpl , err := newTemplate (filepath .Base (templatePath )).ParseFiles (templatePath )
316
321
if err != nil {
317
322
log .Fatalf ("unable to parse template: %s" , err )
318
323
}
You can’t perform that action at this time.
0 commit comments