Add shortcode support for HTML files
authorbep <bjorn.erik.pedersen@gmail.com>
Wed, 6 May 2015 17:11:33 +0000 (19:11 +0200)
committerbep <bjorn.erik.pedersen@gmail.com>
Wed, 6 May 2015 17:11:42 +0000 (19:11 +0200)
Fixes #674

hugolib/handler_page.go

index e2e559f609671a52df949285ed30e2c3697b7ecb..a29b664e94b4e391c461870a02d8835a4c170e07 100644 (file)
@@ -82,9 +82,22 @@ type htmlHandler struct {
 
 func (h htmlHandler) Extensions() []string { return []string{"html", "htm"} }
 func (h htmlHandler) PageConvert(p *Page, t tpl.Template) HandledResult {
-       // see #674 - disabled by bjornerik for now
-       // p.ProcessShortcodes(t)
-       p.Content = helpers.BytesToHTML(p.rawContent)
+       p.ProcessShortcodes(t)
+       var content []byte
+       var err error
+
+       if len(p.contentShortCodes) > 0 {
+               content, err = replaceShortcodeTokens(p.rawContent, shortcodePlaceholderPrefix, true, p.contentShortCodes)
+
+               if err != nil {
+                       jww.FATAL.Printf("Fail to replace shortcode tokens in %s:\n%s", p.BaseFileName(), err.Error())
+                       return HandledResult{err: err}
+               }
+       } else {
+               content = p.rawContent
+       }
+
+       p.Content = helpers.BytesToHTML(content)
        return HandledResult{err: nil}
 }