Commit 6049b174 authored by Daniel Martí's avatar Daniel Martí

html/template: use bytes.ContainsAny

It was added in Go 1.7. Also gofmt while at it.

Change-Id: Idb65fb44e2f2a4365dceea3f833aeb51a8d12333
Reviewed-on: https://go-review.googlesource.com/41692
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 6f45e37b
......@@ -64,7 +64,7 @@ var funcMap = template.FuncMap{
// predefinedEscapers contains template predefined escapers.
var predefinedEscapers = map[string]bool{
"html" : true,
"html": true,
"urlquery": true,
"js": true,
}
......@@ -155,8 +155,8 @@ func (e *escaper) escapeAction(c context, n *parse.ActionNode) context {
for _, ident := range allIdents(idNode.Args[0]) {
if _, ok := predefinedEscapers[ident]; ok {
return context{
state: stateError,
err: errorf(ErrPredefinedEscaper, n, n.Line, "predefined escaper %q disallowed in template", ident),
state: stateError,
err: errorf(ErrPredefinedEscaper, n, n.Line, "predefined escaper %q disallowed in template", ident),
}
}
}
......@@ -582,7 +582,7 @@ func (e *escaper) escapeText(c context, n *parse.TextNode) context {
// the entire comment is considered to be a
// LineTerminator for purposes of parsing by
// the syntactic grammar."
if bytes.IndexAny(s[written:i1], "\n\r\u2028\u2029") != -1 {
if bytes.ContainsAny(s[written:i1], "\n\r\u2028\u2029") {
b.WriteByte('\n')
} else {
b.WriteByte(' ')
......
......@@ -246,7 +246,7 @@ func tAttr(c context, s []byte) (context, int) {
// tURL is the context transition function for the URL state.
func tURL(c context, s []byte) (context, int) {
if bytes.IndexAny(s, "#?") >= 0 {
if bytes.ContainsAny(s, "#?") {
c.urlPart = urlPartQueryOrFrag
} else if len(s) != eatWhiteSpace(s, 0) && c.urlPart == urlPartNone {
// HTML5 uses "Valid URL potentially surrounded by spaces" for
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment