tpl: Fix params case issue with nested template funcs
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 27 Nov 2016 17:01:43 +0000 (18:01 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 27 Nov 2016 18:02:43 +0000 (19:02 +0100)
Fixes #2740

tpl/template_ast_transformers.go
tpl/template_ast_transformers_test.go

index 2020a42e5d805547935d250a789dbc2ee16c190b..19b772addeb4af19506f7bfc5c73753e7fa90dec 100644 (file)
@@ -97,7 +97,10 @@ func (c *templateContext) paramsKeysToLower(n parse.Node) {
                                c.updateIdentsIfNeeded(an.Ident)
                        case *parse.VariableNode:
                                c.updateIdentsIfNeeded(an.Ident)
+                       case *parse.PipeNode:
+                               c.paramsKeysToLower(an)
                        }
+
                }
        }
 }
index ee40cc8e4f97a04907c4286c578e430646628b71..c78c521c91337c8ec390640bd67f566ca60983d6 100644 (file)
@@ -104,6 +104,12 @@ RANGE: {{ . }}: {{ $.Params.LOWER }}
 {{ .NotParam }}
 {{ .NotParam }}
 {{ $notparam }}
+
+
+{{ $lower := .Site.Params.LOWER }}
+F1: {{ printf "themes/%s-theme" .Site.Params.LOWER }}
+F2: {{ Echo (printf "themes/%s-theme" $lower) }}
+F3: {{ Echo (printf "themes/%s-theme" .Site.Params.LOWER) }}
 `
 )
 
@@ -152,6 +158,12 @@ func TestParamsKeysToLower(t *testing.T) {
        require.Contains(t, result, "RANGE: 3: P1L")
 
        require.Contains(t, result, "Hi There")
+
+       // Issue #2740
+       require.Contains(t, result, "F1: themes/P2L-theme")
+       require.Contains(t, result, "F2: themes/P2L-theme")
+       require.Contains(t, result, "F3: themes/P2L-theme")
+
 }
 
 func BenchmarkTemplateParamsKeysToLower(b *testing.B) {