Skip to content

Commit

Permalink
Merge pull request #2 from Wattpad/default-value-fix
Browse files Browse the repository at this point in the history
Handle variable scope for default values correctly
  • Loading branch information
BanglanfengPan authored Mar 7, 2023
2 parents c629a90 + 179c816 commit 890551b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 890551b

Please sign in to comment.