aboutsummaryrefslogtreecommitdiff
path: root/src/html
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-04-10 07:08:45 -0700
committerIan Lance Taylor <iant@golang.org>2018-04-10 14:26:58 +0000
commitd01322826e38fb42d4cf14188164fc46d90e25ae (patch)
tree9295e3a105988534b99dd6fde890a0d50304ef2a /src/html
parentee0aa3965726111689955e248004ce4e48f7bc63 (diff)
downloadgo-d01322826e38fb42d4cf14188164fc46d90e25ae.tar.gz
go-d01322826e38fb42d4cf14188164fc46d90e25ae.zip
text/template: copy Decl field when copying PipeNode
Fixes #24791 Change-Id: I62ac17313e6e09796586911d88191a36d67f9aa1 Reviewed-on: https://go-review.googlesource.com/106115 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/html')
-rw-r--r--src/html/template/clone_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/html/template/clone_test.go b/src/html/template/clone_test.go
index b500715ac6..e292321d93 100644
--- a/src/html/template/clone_test.go
+++ b/src/html/template/clone_test.go
@@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"io/ioutil"
+ "strings"
"sync"
"testing"
"text/template/parse"
@@ -262,3 +263,17 @@ func TestCloneRedefinedName(t *testing.T) {
}
}
}
+
+// Issue 24791.
+func TestClonePipe(t *testing.T) {
+ a := Must(New("a").Parse(`{{define "a"}}{{range $v := .A}}{{$v}}{{end}}{{end}}`))
+ data := struct{ A []string }{A: []string{"hi"}}
+ b := Must(a.Clone())
+ var buf strings.Builder
+ if err := b.Execute(&buf, &data); err != nil {
+ t.Fatal(err)
+ }
+ if got, want := buf.String(), "hi"; got != want {
+ t.Errorf("got %q want %q", got, want)
+ }
+}