mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings
This commit is contained in:
@@ -149,8 +149,12 @@ func interfaceToString(i interface{}) string {
|
|||||||
switch s := i.(type) {
|
switch s := i.(type) {
|
||||||
case string:
|
case string:
|
||||||
return s
|
return s
|
||||||
|
case float64:
|
||||||
|
return strconv.FormatFloat(i.(float64), 'f', -1, 64)
|
||||||
|
case int:
|
||||||
|
return strconv.FormatInt(int64(i.(int)), 10)
|
||||||
default:
|
default:
|
||||||
errorf("Only Strings are supported for this key")
|
errorf(fmt.Sprintf("Only Strings are supported for this key (got type '%T'): %s", s, s))
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
Reference in New Issue
Block a user