Commit 9d2e9268 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

template/interpolate: filter is case insensitive

parent 41a6fe9f
...@@ -74,14 +74,14 @@ func (f *RenderFilter) include(k string) bool { ...@@ -74,14 +74,14 @@ func (f *RenderFilter) include(k string) bool {
} }
f.once.Do(f.init) f.once.Do(f.init)
_, ok := f.includeSet[k] _, ok := f.includeSet[strings.ToLower(k)]
return ok return ok
} }
func (f *RenderFilter) init() { func (f *RenderFilter) init() {
f.includeSet = make(map[string]struct{}) f.includeSet = make(map[string]struct{})
for _, v := range f.Include { for _, v := range f.Include {
f.includeSet[v] = struct{}{} f.includeSet[strings.ToLower(v)] = struct{}{}
} }
} }
......
...@@ -76,6 +76,24 @@ func TestRenderMap(t *testing.T) { ...@@ -76,6 +76,24 @@ func TestRenderMap(t *testing.T) {
Include: []string{"bar"}, Include: []string{"bar"},
}, },
}, },
"filter case-insensitive": {
map[string]interface{}{
"bar": "{{upper `baz`}}",
"foo": map[string]string{
"{{upper `bar`}}": "{{upper `baz`}}",
},
},
map[string]interface{}{
"bar": "BAZ",
"foo": map[string]string{
"{{upper `bar`}}": "{{upper `baz`}}",
},
},
&RenderFilter{
Include: []string{"baR"},
},
},
} }
ctx := &Context{} ctx := &Context{}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment