From e68190ca6ab1a6da3e3575a7b066ef2152d67d55 Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Wed, 1 Nov 2023 11:31:51 -0700 Subject: [PATCH] Use buffered writer --- salix.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/salix.go b/salix.go index 5783300..c378ef1 100644 --- a/salix.go +++ b/salix.go @@ -19,6 +19,7 @@ package salix import ( + "bufio" "errors" "fmt" "html" @@ -97,7 +98,9 @@ func (t Template) WithEscapeHTML(b bool) Template { // the result to w. func (t Template) Execute(w io.Writer) error { t.macros = map[string][]ast.Node{} - return t.execute(w, t.ast, nil) + bw := bufio.NewWriterSize(w, 16384) + defer bw.Flush() + return t.execute(bw, t.ast, nil) } func (t *Template) execute(w io.Writer, nodes []ast.Node, local map[string]any) error {