shithub: hugo

Download patch

ref: ed0fe9ddf7b1c5df1d190979a0005747815b732a
parent: b41622bc49e3a1a7281dfcd54de0184a10c7a77f
author: Ask Bjørn Hansen <[email protected]>
date: Sun Feb 16 20:26:46 EST 2014

Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings

--- a/hugolib/metadata.go
+++ b/hugolib/metadata.go
@@ -149,8 +149,12 @@
 	switch s := i.(type) {
 	case string:
 		return s
+	case float64:
+		return strconv.FormatFloat(i.(float64), 'f', -1, 64)
+	case int:
+		return strconv.FormatInt(int64(i.(int)), 10)
 	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 ""