1
0
mirror of https://github.com/danog/gojekyll.git synced 2025-01-23 06:51:25 +01:00

page.content doesn't include layouts

This commit is contained in:
Oliver Steele 2017-07-01 09:35:54 -04:00
parent e7c0ac5fc8
commit 5f406b6df0
2 changed files with 13 additions and 15 deletions

View File

@ -58,7 +58,7 @@ func (c *Collection) TemplateVariable(ctx pages.RenderingContext, includeContent
v := p.PageVariables()
dp, ok := p.(*pages.Page)
if includeContent && ok {
c, err := dp.ComputeContent(ctx)
c, err := dp.Content(ctx)
if err != nil {
return nil, err
}

View File

@ -14,7 +14,7 @@ import (
type Page struct {
file
raw []byte
processed *[]byte
content *[]byte
}
// Static is in the File interface.
@ -98,10 +98,6 @@ func (p *Page) TemplateContext(rc RenderingContext) map[string]interface{} {
// Write applies Liquid and Markdown, as appropriate.
func (p *Page) Write(rc RenderingContext, w io.Writer) error {
rp := rc.RenderingPipeline()
if p.processed != nil {
_, err := w.Write(*p.processed)
return err
}
b, err := rp.Render(w, p.raw, p.filename, p.TemplateContext(rc))
if err != nil {
return err
@ -117,15 +113,17 @@ func (p *Page) Write(rc RenderingContext, w io.Writer) error {
return err
}
// ComputeContent computes the page content.
func (p *Page) ComputeContent(rc RenderingContext) ([]byte, error) {
if p.processed == nil {
w := new(bytes.Buffer)
if err := p.Write(rc, w); err != nil {
// Content computes the page content.
func (p *Page) Content(rc RenderingContext) ([]byte, error) {
if p.content == nil {
// TODO DRY w/ Page.Write
rp := rc.RenderingPipeline()
buf := new(bytes.Buffer)
b, err := rp.Render(buf, p.raw, p.filename, p.TemplateContext(rc))
if err != nil {
return nil, err
}
b := w.Bytes()
p.processed = &b
p.content = &b
}
return *p.processed, nil
return *p.content, nil
}