From 179c81608527f827ba3d703a399e3848f3beea32 Mon Sep 17 00:00:00 2001 From: "Ryan J. Geyer" Date: Fri, 30 Jul 2021 16:36:42 -0700 Subject: [PATCH] Handle variable scope for default values correctly --- pkg/template/template.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/template/template.go b/pkg/template/template.go index 6329ed2..01f359f 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -110,11 +110,13 @@ func (t *dirTemplate) UseDefaultValues() { } func (t *dirTemplate) BindPrompts() { - for s, v := range t.Context { + for s, ov := range t.Context { + var v = ov if m, ok := v.(map[string]interface{}); ok { advancedMode := prompt.New(s, false) - for k, v2 := range m { + for k, ov2 := range m { + var v2 = ov2 if t.ShouldUseDefaults { t.FuncMap[k] = func() interface{} { switch v2 := v2.(type) {