Skip to content

Commit

Permalink
Centralizing the template execution logic in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
spf13 committed Jun 6, 2014
1 parent c297d74 commit 4483a66
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions hugolib/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,25 +508,7 @@ func (p *Page) Render(layout ...string) template.HTML {
curLayout = layout[0]
}

return bytesToHTML(p.ExecuteTemplate(curLayout).Bytes())
}

func (p *Page) ExecuteTemplate(layout string) *bytes.Buffer {
l := p.Layout(layout)
buffer := new(bytes.Buffer)
worked := false
for _, layout := range l {
if p.Tmpl.Lookup(layout) != nil {
p.Tmpl.ExecuteTemplate(buffer, layout, p)
worked = true
break
}
}
if !worked {
jww.ERROR.Println("Unable to render", layout, ".")
jww.ERROR.Println("Expecting to find a template in either the theme/layouts or /layouts in one of the following relative locations", l)
}
return buffer
return ExecuteTemplateToHTML(p, p.Layout(curLayout)...)
}

func (page *Page) guessMarkupType() string {
Expand Down

0 comments on commit 4483a66

Please sign in to comment.