From 0e04b9a0292732c20cc90e1f05c2f4ee200634d8 Mon Sep 17 00:00:00 2001 From: spf13 Date: Fri, 6 Dec 2013 23:57:24 -0500 Subject: [PATCH] Moving processing short codes to the page --- hugolib/page.go | 5 +++++ hugolib/site.go | 12 ++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hugolib/page.go b/hugolib/page.go index 817dec868..50d8786f3 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -240,6 +240,11 @@ func ReadFrom(buf io.Reader, name string) (page *Page, err error) { return p, nil } +func (p *Page) ProcessShortcodes(t bundle.Template) { + p.Content = template.HTML(ShortcodesHandle(string(p.Content), p, t)) + p.Summary = template.HTML(ShortcodesHandle(string(p.Summary), p, t)) +} + func (p *Page) analyzePage() { p.WordCount = TotalWords(p.Plain()) p.FuzzyWordCount = int((p.WordCount+100)/100) * 100 diff --git a/hugolib/site.go b/hugolib/site.go index c50d9bd77..ef27d0979 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -264,13 +264,6 @@ func (s *Site) checkDirectories() (err error) { return } -func (s *Site) ProcessShortcodes() { - for _, page := range s.Pages { - page.Content = template.HTML(ShortcodesHandle(string(page.Content), page, s.Tmpl)) - page.Summary = template.HTML(ShortcodesHandle(string(page.Summary), page, s.Tmpl)) - } -} - func (s *Site) CreatePages() (err error) { if s.Source == nil { panic(fmt.Sprintf("s.Source not set %s", s.absContentDir())) @@ -288,9 +281,8 @@ func (s *Site) CreatePages() (err error) { page.Section = file.Section page.Dir = file.Dir - // Handling short codes prior to Conversion to HTML - page.Content = template.HTML(ShortcodesHandle(string(page.Content), page, s.Tmpl)) - page.Summary = template.HTML(ShortcodesHandle(string(page.Summary), page, s.Tmpl)) + //Handling short codes prior to Conversion to HTML + page.ProcessShortcodes(s.Tmpl) err = page.Convert() if err != nil {