template/interpolate: filter is case insensitive
This commit is contained in:
parent
41a6fe9fda
commit
9d2e926808
|
@ -74,14 +74,14 @@ func (f *RenderFilter) include(k string) bool {
|
|||
}
|
||||
|
||||
f.once.Do(f.init)
|
||||
_, ok := f.includeSet[k]
|
||||
_, ok := f.includeSet[strings.ToLower(k)]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (f *RenderFilter) init() {
|
||||
f.includeSet = make(map[string]struct{})
|
||||
for _, v := range f.Include {
|
||||
f.includeSet[v] = struct{}{}
|
||||
f.includeSet[strings.ToLower(v)] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,24 @@ func TestRenderMap(t *testing.T) {
|
|||
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{}
|
||||
|
|
Loading…
Reference in New Issue