mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-30 00:23:24 -05:00
Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings
This commit is contained in:
parent
b41622bc49
commit
ed0fe9ddf7
1 changed files with 5 additions and 1 deletions
|
@ -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 ""
|
||||||
|
|
Loading…
Reference in a new issue