ref: 1882ffabc603a1a5a81b536157610dbbb4e1bd6a
parent: 1da3fd039a4ce4d1193a996b58dd5bae8c6e00e7
author: spf13 <[email protected]>
date: Tue Jan 28 18:24:59 EST 2014
Adding support for boolean params
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -412,6 +412,8 @@
default:
// If not one of the explicit values, store in Params
switch vv := v.(type) {
+ case bool:
+ page.Params[loki] = vv
case string:
page.Params[loki] = vv
case int64, int32, int16, int8, int:
@@ -444,6 +446,8 @@
}
switch v.(type) {
+ case bool:
+ return interfaceToBool(v)
case string:
return interfaceToString(v)
case int64, int32, int16, int8, int:
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -209,6 +209,7 @@
a_string = "bar"
an_integer = 1
a_float = 1.3
+a_bool = false
a_date = 1979-05-27T07:32:00Z
+++
Front Matter with various frontmatter types`
@@ -457,6 +458,9 @@
}
if page.GetParam("a_float") != 1.3 {
t.Errorf("frontmatter not handling floats correctly should be %s, got: %s", 1.3, page.GetParam("a_float"))
+ }
+ if page.GetParam("a_bool") != false {
+ t.Errorf("frontmatter not handling bools correctly should be %s, got: %s", false, page.GetParam("a_bool"))
}
if page.GetParam("a_date") != dateval {
t.Errorf("frontmatter not handling dates correctly should be %s, got: %s", dateval, page.GetParam("a_date"))