This repository has been archived by the owner on Jun 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
html/template: include itself while cloning
template.Clone() initialized template set incorrectly: it didn't include itself. * include itself in template set while cloning * add a test Fixes golang#12996 Change-Id: I932530e4f7f1bbebf833e12b000a5ce052bc9223 Reviewed-on: https://go-review.googlesource.com/16104 Reviewed-by: Andrew Gerrand <[email protected]>
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package template | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
) | ||
|
||
func TestTemplateClone(t *testing.T) { | ||
// https://golang.org/issue/12996 | ||
orig := New("name") | ||
clone, err := orig.Clone() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(clone.Templates()) != len(orig.Templates()) { | ||
t.Fatalf("Invalid lenth of t.Clone().Templates()") | ||
} | ||
|
||
const want = "stuff" | ||
parsed := Must(clone.Parse(want)) | ||
var buf bytes.Buffer | ||
err = parsed.Execute(&buf, nil) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if got := buf.String(); got != want { | ||
t.Fatalf("got %q; want %q", got, want) | ||
} | ||
} |