Handle empty front matter in archetype.
authorJonathan Anderson <jonathan.anderson@ieee.org>
Sat, 24 Jan 2015 01:26:29 +0000 (21:56 -0330)
committerbep <bjorn.erik.pedersen@gmail.com>
Sat, 24 Jan 2015 09:46:52 +0000 (10:46 +0100)
If an archetype has deliberately empty front matter (e.g., to suppress
generation of the 'draft' field or to force a particular front matter type
instead of the default TOML), we should handle it gracefully rather than
panic ("assignment to entry in nil map").

create/content.go

index c3c1747a2cce54c35b186794e8fa19d4a8415205..98b3652a4e084c01521abcb1bb33ec8870371f2a 100644 (file)
@@ -81,6 +81,10 @@ func NewContent(kind, name string) (err error) {
                return false
        }
 
+       if newmetadata == nil {
+               newmetadata = make(map[string]interface{})
+       }
+
        if !caseimatch(newmetadata, "date") {
                newmetadata["date"] = time.Now()
        }