1
0
mirror of https://github.com/golang/go synced 2024-11-14 08:40:27 -07:00

text/template/parse: mostly roll back the error detection for unmatched right delimiters

It's too late to change this behavior: it breaks templates with minimized JavaScript.

Makes me sad because this common error can never be caught: "{foo}}".
Three cheers for compatibility.

(Leave in a fix to a broken test.)

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/13689043
This commit is contained in:
Rob Pike 2013-09-13 12:44:45 +10:00
parent 913f1f1557
commit c842e43ef6
2 changed files with 4 additions and 5 deletions

View File

@ -217,10 +217,6 @@ func lexText(l *lexer) stateFn {
} }
return lexLeftDelim return lexLeftDelim
} }
// Check for right after left in case they're the same.
if strings.HasPrefix(l.input[l.pos:], l.rightDelim) {
return l.errorf("unmatched right delimiter")
}
if l.next() == eof { if l.next() == eof {
break break
} }

View File

@ -340,8 +340,11 @@ var lexTests = []lexTest{
{itemText, 0, "hello-"}, {itemText, 0, "hello-"},
{itemError, 0, `comment ends before closing delimiter`}, {itemError, 0, `comment ends before closing delimiter`},
}}, }},
// This one is an error that we can't catch because it breaks templates with
// minimized JavaScript. Should have fixed it before Go 1.1.
{"unmatched right delimiter", "hello-{.}}-world", []item{ {"unmatched right delimiter", "hello-{.}}-world", []item{
{itemError, 0, `unmatched right delimiter`}, {itemText, 0, "hello-{.}}-world"},
tEOF,
}}, }},
} }