Make Page.Content a method that returns interface{}

To prepare for a `Resource.Content` method.

See #4622
This commit is contained in:
Bjørn Erik Pedersen
2018-04-15 16:42:54 +02:00
parent 94c8b29c39
commit 417c5e2b67
8 changed files with 28 additions and 24 deletions

View File

@@ -128,7 +128,7 @@ type Page struct {
params map[string]interface{}
// Content sections
Content template.HTML
content template.HTML
Summary template.HTML
TableOfContents template.HTML
@@ -263,6 +263,10 @@ type Page struct {
targetPathDescriptorPrototype *targetPathDescriptor
}
func (p *Page) Content() (interface{}, error) {
return p.content, nil
}
// Sites is a convenience method to get all the Hugo sites/languages configured.
func (p *Page) Sites() SiteInfos {
infos := make(SiteInfos, len(p.s.owner.Sites))
@@ -462,7 +466,7 @@ func (p *Page) PlainWords() []string {
func (p *Page) initPlain() {
p.plainInit.Do(func() {
p.plain = helpers.StripHTML(string(p.Content))
p.plain = helpers.StripHTML(string(p.content))
return
})
}
@@ -1098,7 +1102,7 @@ func (p *Page) prepareForRender(cfg *BuildCfg) error {
workContentCopy = summaryContent.content
}
p.Content = helpers.BytesToHTML(workContentCopy)
p.content = helpers.BytesToHTML(workContentCopy)
if summaryContent == nil {
if err := p.setAutoSummary(); err != nil {
@@ -1107,7 +1111,7 @@ func (p *Page) prepareForRender(cfg *BuildCfg) error {
}
} else {
p.Content = helpers.BytesToHTML(workContentCopy)
p.content = helpers.BytesToHTML(workContentCopy)
}
//analyze for raw stats
@@ -1720,7 +1724,7 @@ func (p *Page) prepareLayouts() error {
if p.Kind == KindPage {
if !p.IsRenderable() {
self := "__" + p.UniqueID()
err := p.s.TemplateHandler().AddLateTemplate(self, string(p.Content))
err := p.s.TemplateHandler().AddLateTemplate(self, string(p.content))
if err != nil {
return err
}