From: Gustavo Niemeyer Date: Thu, 19 Jan 2012 23:49:28 +0000 (-0200) Subject: html/template: fix docs after API changes X-Git-Tag: weekly.2012-01-20~4 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=369454d7b2f3b03ee5bdfde1eae6092bace14951;p=gostls13.git html/template: fix docs after API changes R=golang-dev, r CC=golang-dev https://golang.org/cl/5528109 --- diff --git a/src/pkg/html/template/doc.go b/src/pkg/html/template/doc.go index fc0e382644..77a9bf2e22 100644 --- a/src/pkg/html/template/doc.go +++ b/src/pkg/html/template/doc.go @@ -31,8 +31,8 @@ Example import "text/template" ... - t, err := (&template.Set{}).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) - err = t.Execute(out, "T", "") + t, err := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) + err = t.ExecuteTemplate(out, "T", "") produces @@ -42,12 +42,12 @@ but with contextual autoescaping, import "html/template" ... - t, err := (&template.Set{}).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) - err = t.Execute(out, "T", "") + t, err := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`) + err = t.ExecuteTemplate(out, "T", "") produces safe, escaped HTML output - Hello, <script>alert('you have been pwned')</script>! + Hello, <script>alert('you have been pwned')</script>! Contexts @@ -57,8 +57,8 @@ functions to each simple action pipeline, so given the excerpt {{.}} -At parse time each {{.}} is overwritten to add escaping functions as necessary, -in this case, +At parse time each {{.}} is overwritten to add escaping functions as necessary. +In this case it becomes {{. | html}}