Centralizing the template execution logic in one place - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 4483a6655a50d5314b46328bf3afdf0649323bd4
DIR parent c297d7451f6e71c9e790802ce807625a260da443
HTML Author: spf13 <steve.francia@gmail.com>
Date: Fri, 6 Jun 2014 16:38:19 -0400
Centralizing the template execution logic in one place
Diffstat:
M hugolib/page.go | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
---
DIR diff --git a/hugolib/page.go b/hugolib/page.go
@@ -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 {