diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-07-16 06:54:42 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-07-16 06:54:42 +0000 |
commit | f4ca453c9530ff24478cae090c9979b97fdd7411 (patch) | |
tree | 0e8fda573576bb4181dba29d0e88380a8c38fafd /libgo/go/html | |
parent | 84a4a7d4b2fecf754bc0b7fce55b05912a054ef4 (diff) | |
download | gcc-f4ca453c9530ff24478cae090c9979b97fdd7411.tar.gz |
libgo: Update to Go 1.1.1.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200974 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/html')
-rw-r--r-- | libgo/go/html/template/doc.go | 2 | ||||
-rw-r--r-- | libgo/go/html/template/template.go | 22 | ||||
-rw-r--r-- | libgo/go/html/template/transition.go | 3 |
3 files changed, 15 insertions, 12 deletions
diff --git a/libgo/go/html/template/doc.go b/libgo/go/html/template/doc.go index f470facfd0c..d422ada37a7 100644 --- a/libgo/go/html/template/doc.go +++ b/libgo/go/html/template/doc.go @@ -119,7 +119,7 @@ If {{.}} is the innocuous word, `left`, then it can appear more widely, Non-string values can be used in JavaScript contexts. If {{.}} is - []struct{A,B string}{ "foo", "bar" } + struct{A,B string}{ "foo", "bar" } in the escaped template diff --git a/libgo/go/html/template/template.go b/libgo/go/html/template/template.go index 768cee7d5fd..e183898d50f 100644 --- a/libgo/go/html/template/template.go +++ b/libgo/go/html/template/template.go @@ -45,18 +45,24 @@ func (t *Template) Templates() []*Template { return m } -// Execute applies a parsed template to the specified data object, -// writing the output to wr. -func (t *Template) Execute(wr io.Writer, data interface{}) (err error) { +// escape escapes all associated templates. +func (t *Template) escape() error { t.nameSpace.mu.Lock() + defer t.nameSpace.mu.Unlock() if !t.escaped { - if err = escapeTemplates(t, t.Name()); err != nil { - t.escaped = true + if err := escapeTemplates(t, t.Name()); err != nil { + return err } + t.escaped = true } - t.nameSpace.mu.Unlock() - if err != nil { - return + return nil +} + +// Execute applies a parsed template to the specified data object, +// writing the output to wr. +func (t *Template) Execute(wr io.Writer, data interface{}) error { + if err := t.escape(); err != nil { + return err } return t.text.Execute(wr, data) } diff --git a/libgo/go/html/template/transition.go b/libgo/go/html/template/transition.go index 96a4f6678bc..564eb202075 100644 --- a/libgo/go/html/template/transition.go +++ b/libgo/go/html/template/transition.go @@ -71,7 +71,6 @@ func tText(c context, s []byte) (context, int) { } k = j } - panic("unreachable") } var elementContentType = [...]state{ @@ -430,7 +429,6 @@ func tCSS(c context, s []byte) (context, int) { } k = i + 1 } - panic("unreachable") } // tCSSStr is the context transition function for the CSS string and URL states. @@ -471,7 +469,6 @@ func tCSSStr(c context, s []byte) (context, int) { c, _ = tURL(c, decodeCSS(s[:i+1])) k = i + 1 } - panic("unreachable") } // tError is the context transition function for the error state. |