Fix Params case handling in the index, sort and where func

This means that you can now do:

```
{{ range where .Site.Pages "Params.MYPARAM" "foo" }}
```
This commit is contained in:
Bjørn Erik Pedersen
2019-11-21 21:59:38 +01:00
parent cd07e6d57b
commit a3fe5e5e35
33 changed files with 317 additions and 155 deletions

View File

@@ -19,12 +19,16 @@ import (
"github.com/spf13/cast"
)
func Param(r ResourceParamsProvider, fallback map[string]interface{}, key interface{}) (interface{}, error) {
func Param(r ResourceParamsProvider, fallback maps.Params, key interface{}) (interface{}, error) {
keyStr, err := cast.ToStringE(key)
if err != nil {
return nil, err
}
if fallback == nil {
return maps.GetNestedParam(keyStr, ".", r.Params())
}
return maps.GetNestedParam(keyStr, ".", r.Params(), fallback)
}