hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 5441fc5dfc056a4e4dfd34ca16f0928e482b4c29
parent 2f2297bdb324471be3976809dfc545e211b4db08
Author: spf13 <steve.francia@gmail.com>
Date:   Fri, 30 Jan 2015 11:25:54 -0800

template render with BBP

Diffstat:
Mtpl/template.go | 23++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/tpl/template.go b/tpl/template.go
@@ -17,11 +17,6 @@ import (
 	"bytes"
 	"errors"
 	"fmt"
-	"github.com/eknkc/amber"
-	"github.com/spf13/cast"
-	"github.com/spf13/hugo/helpers"
-	jww "github.com/spf13/jwalterweatherman"
-	"github.com/yosssi/ace"
 	"html"
 	"html/template"
 	"io"
@@ -32,6 +27,13 @@ import (
 	"sort"
 	"strconv"
 	"strings"
+
+	"github.com/eknkc/amber"
+	"github.com/spf13/cast"
+	bp "github.com/spf13/hugo/bufferpool"
+	"github.com/spf13/hugo/helpers"
+	jww "github.com/spf13/jwalterweatherman"
+	"github.com/yosssi/ace"
 )
 
 var localTemplates *template.Template
@@ -1101,8 +1103,7 @@ func Partial(name string, context_list ...interface{}) template.HTML {
 	return ExecuteTemplateToHTML(context, "partials/"+name, "theme/partials/"+name)
 }
 
-func ExecuteTemplate(context interface{}, layouts ...string) *bytes.Buffer {
-	buffer := new(bytes.Buffer)
+func ExecuteTemplate(context interface{}, buffer *bytes.Buffer, layouts ...string) {
 	worked := false
 	for _, layout := range layouts {
 
@@ -1125,13 +1126,13 @@ func ExecuteTemplate(context interface{}, layouts ...string) *bytes.Buffer {
 		jww.ERROR.Println("Unable to render", layouts)
 		jww.ERROR.Println("Expecting to find a template in either the theme/layouts or /layouts in one of the following relative locations", layouts)
 	}
-
-	return buffer
 }
 
 func ExecuteTemplateToHTML(context interface{}, layouts ...string) template.HTML {
-	b := ExecuteTemplate(context, layouts...)
-	return template.HTML(string(b.Bytes()))
+	b := bp.GetBuffer()
+	defer bp.PutBuffer(b)
+	ExecuteTemplate(context, b, layouts...)
+	return template.HTML(b.String())
 }
 
 func (t *GoHtmlTemplate) LoadEmbedded() {