diff options
| author | Nigel Tao <nigeltao@golang.org> | 2012-02-15 16:16:30 +1100 |
|---|---|---|
| committer | Nigel Tao <nigeltao@golang.org> | 2012-02-15 16:16:30 +1100 |
| commit | 0c5239410e90f14dadf87d73a7d8e9161eb0bec0 (patch) | |
| tree | 6139b6d1f9af82287af34c322645dfbc5464a175 /src/pkg/text | |
| parent | aca8071fd53fc4f60771fe816b1e7c20c5c674fb (diff) | |
| download | go-0c5239410e90f14dadf87d73a7d8e9161eb0bec0.tar.xz | |
html/template: add Clone and AddParseTree. Make text/template's Clone
return (*Template, error), not just *Template.
Fixes #2757.
R=r
CC=golang-dev
https://golang.org/cl/5665044
Diffstat (limited to 'src/pkg/text')
| -rw-r--r-- | src/pkg/text/template/multi_test.go | 2 | ||||
| -rw-r--r-- | src/pkg/text/template/template.go | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/pkg/text/template/multi_test.go b/src/pkg/text/template/multi_test.go index 274f5ef147..f205e6be1b 100644 --- a/src/pkg/text/template/multi_test.go +++ b/src/pkg/text/template/multi_test.go @@ -193,7 +193,7 @@ func TestClone(t *testing.T) { if err != nil { t.Fatal(err) } - clone := root.Clone() + clone := Must(root.Clone()) // Add variants to both. _, err = root.Parse(cloneText3) if err != nil { diff --git a/src/pkg/text/template/template.go b/src/pkg/text/template/template.go index 87e39d3af7..7494f9d8c4 100644 --- a/src/pkg/text/template/template.go +++ b/src/pkg/text/template/template.go @@ -69,9 +69,9 @@ func (t *Template) init() { // templates. The actual representation is not copied, but the name space of // associated templates is, so further calls to Parse in the copy will add // templates to the copy but not to the original. Clone can be used to prepare -// common templates and use them with variant definitions for other templates by -// adding the variants after the clone is made. -func (t *Template) Clone() *Template { +// common templates and use them with variant definitions for other templates +// by adding the variants after the clone is made. +func (t *Template) Clone() (*Template, error) { nt := t.copy(nil) nt.init() nt.tmpl[t.name] = nt @@ -89,7 +89,7 @@ func (t *Template) Clone() *Template { for k, v := range t.execFuncs { nt.execFuncs[k] = v } - return nt + return nt, nil } // copy returns a shallow copy of t, with common set to the argument. |
