From ad42ce37ff411fccbcfe5d441e2babb8eb2244ed Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 9 May 2019 02:09:34 +0700 Subject: filehtml: save other metadata as map of string to string One can use the map in template using the following syntax {{ index .Metadata "key" }} --- filehtml.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'filehtml.go') diff --git a/filehtml.go b/filehtml.go index 766fbed..a31b28a 100644 --- a/filehtml.go +++ b/filehtml.go @@ -13,9 +13,10 @@ import ( // fileHTML represent an HTML metadata for header and its body. // type fileHTML struct { - Title string - Styles []string - Body template.HTML + Title string + Styles []string + Body template.HTML + Metadata map[string]string path string rawBody strings.Builder @@ -38,12 +39,16 @@ func (fhtml *fileHTML) reset() { // rawBody to template.HTML. // func (fhtml *fileHTML) unpackAdoc(fa *fileAdoc) { + fhtml.Metadata = make(map[string]string) + for k, v := range fa.metadata { switch k { case "doctitle": fhtml.Title = v.(string) case "stylesheet": fhtml.Styles = append(fhtml.Styles, v.(string)) + default: + fhtml.Metadata[k] = v.(string) } } -- cgit v1.3