diff options
| author | Shulhan <ms@kilabit.info> | 2019-05-09 02:09:34 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-05-09 02:09:34 +0700 |
| commit | ad42ce37ff411fccbcfe5d441e2babb8eb2244ed (patch) | |
| tree | 555c273002c55e72c7169fc302e25501bd4fc53a | |
| parent | 542b5a492f17e6f8e2d2d17dcd06ee26ae257ea6 (diff) | |
| download | ciigo-ad42ce37ff411fccbcfe5d441e2babb8eb2244ed.tar.xz | |
filehtml: save other metadata as map of string to string
One can use the map in template using the following syntax
{{ index .Metadata "key" }}
| -rw-r--r-- | filehtml.go | 11 |
1 files changed, 8 insertions, 3 deletions
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) } } |
