Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
369454d7
Commit
369454d7
authored
Jan 19, 2012
by
Gustavo Niemeyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
html/template: fix docs after API changes
R=golang-dev, r CC=golang-dev
https://golang.org/cl/5528109
parent
6454a3eb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
src/pkg/html/template/doc.go
src/pkg/html/template/doc.go
+7
-7
No files found.
src/pkg/html/template/doc.go
View file @
369454d7
...
...
@@ -31,8 +31,8 @@ Example
import "text/template"
...
t, err :=
(&template.Set{}
).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
err = t.Execute(out, "T", "<script>alert('you have been pwned')</script>")
t, err :=
template.New("foo"
).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
err = t.Execute
Template
(out, "T", "<script>alert('you have been pwned')</script>")
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", "<script>alert('you have been pwned')</script>")
t, err :=
template.New("foo"
).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
err = t.Execute
Template
(out, "T", "<script>alert('you have been pwned')</script>")
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
<a href="/search?q={{.}}">{{.}}</a>
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
<a href="/search?q={{. | urlquery}}">{{. | html}}</a>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment