mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Fix for page.GetParam() for JSON and TOML maps
Setting per-page Blackfriday angledQuotes did not work with TOML or JSON front matter, but it does work with YAML. It turns out that page.Params("blackfriday") returns type map[interface{}]interface{} for YAML, but type map[string]interface{} for JSON and TOML. This patch updates page.GetParam() to catch the latter, with an error message if page.GetParam() does not recognize a type. A test is also added.
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/spf13/hugo/helpers"
|
||||
"github.com/spf13/hugo/parser"
|
||||
"reflect"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
"github.com/spf13/hugo/hugofs"
|
||||
@@ -522,9 +523,13 @@ func (page *Page) GetParam(key string) interface{} {
|
||||
return cast.ToTime(v)
|
||||
case []string:
|
||||
return helpers.SliceToLower(v.([]string))
|
||||
case map[interface{}]interface{}:
|
||||
case map[string]interface{}: // JSON and TOML
|
||||
return v
|
||||
case map[interface{}]interface{}: // YAML
|
||||
return v
|
||||
}
|
||||
|
||||
jww.ERROR.Printf("GetParam(\"%s\"): Unknown type %s\n", key, reflect.TypeOf(v))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user