mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Replace *bytes.Buffer with io.Writer in rendering
Found via github.com/mvdan/interfacer.
This commit is contained in:
parent
4c596483e1
commit
7c5a1fd16b
2 changed files with 4 additions and 5 deletions
|
@ -1691,14 +1691,14 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) render(name string, d interface{}, renderBuffer *bytes.Buffer, layouts ...string) error {
|
func (s *Site) render(name string, d interface{}, w io.Writer, layouts ...string) error {
|
||||||
layout, found := s.findFirstLayout(layouts...)
|
layout, found := s.findFirstLayout(layouts...)
|
||||||
if found == false {
|
if found == false {
|
||||||
jww.WARN.Printf("Unable to locate layout for %s: %s\n", name, layouts)
|
jww.WARN.Printf("Unable to locate layout for %s: %s\n", name, layouts)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.renderThing(d, layout, renderBuffer); err != nil {
|
if err := s.renderThing(d, layout, w); err != nil {
|
||||||
// Behavior here should be dependent on if running in server or watch mode.
|
// Behavior here should be dependent on if running in server or watch mode.
|
||||||
distinctErrorLogger.Printf("Error while rendering %s: %v", name, err)
|
distinctErrorLogger.Printf("Error while rendering %s: %v", name, err)
|
||||||
if !s.Running() {
|
if !s.Running() {
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
package tpl
|
package tpl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/eknkc/amber"
|
"github.com/eknkc/amber"
|
||||||
bp "github.com/spf13/hugo/bufferpool"
|
bp "github.com/spf13/hugo/bufferpool"
|
||||||
|
@ -104,7 +103,7 @@ func Partial(name string, context_list ...interface{}) template.HTML {
|
||||||
return ExecuteTemplateToHTML(context, "partials/"+name, "theme/partials/"+name)
|
return ExecuteTemplateToHTML(context, "partials/"+name, "theme/partials/"+name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExecuteTemplate(context interface{}, buffer *bytes.Buffer, layouts ...string) {
|
func ExecuteTemplate(context interface{}, w io.Writer, layouts ...string) {
|
||||||
worked := false
|
worked := false
|
||||||
for _, layout := range layouts {
|
for _, layout := range layouts {
|
||||||
|
|
||||||
|
@ -115,7 +114,7 @@ func ExecuteTemplate(context interface{}, buffer *bytes.Buffer, layouts ...strin
|
||||||
}
|
}
|
||||||
|
|
||||||
if localTemplates.Lookup(name) != nil {
|
if localTemplates.Lookup(name) != nil {
|
||||||
err := localTemplates.ExecuteTemplate(buffer, name, context)
|
err := localTemplates.ExecuteTemplate(w, name, context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jww.ERROR.Println(err, "in", name)
|
jww.ERROR.Println(err, "in", name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue