tpl: Fix params case issue with nested template funcs - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 046320d3f41e8331583da2ec896ca563eef6dbcb
DIR parent c38bfda43bde093aa5f3b3245e3d2de5190d1991
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sun, 27 Nov 2016 18:01:43 +0100
tpl: Fix params case issue with nested template funcs
Fixes #2740
Diffstat:
M tpl/template_ast_transformers.go | 3 +++
M tpl/template_ast_transformers_test… | 12 ++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
---
DIR diff --git a/tpl/template_ast_transformers.go b/tpl/template_ast_transformers.go
@@ -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)
}
+
}
}
}
DIR diff --git a/tpl/template_ast_transformers_test.go b/tpl/template_ast_transformers_test.go
@@ -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) {