text/template: allow newlines in raw quotes
This was disallowed for error-checking reasons but people ask for
it, it's easy, and it's clear what it all means.
Fixes #7323.
Change-Id: I26542f5ac6519e45b335ad789713a4d9e356279b
Reviewed-on: https://go-review.googlesource.com/9537
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go
index 8c4e165..27c74eb 100644
--- a/src/text/template/exec_test.go
+++ b/src/text/template/exec_test.go
@@ -1095,3 +1095,16 @@
t.Errorf("expected error; got none")
}
}
+
+// Test that the error message for multiline unterminated string
+// refers to the line number of the opening quote.
+func TestUnterminatedStringError(t *testing.T) {
+ _, err := New("X").Parse("hello\n\n{{`unterminated\n\n\n\n}}\n some more\n\n")
+ if err == nil {
+ t.Fatal("expected error")
+ }
+ str := err.Error()
+ if !strings.Contains(str, "X:3: unexpected unterminated raw quoted strin") {
+ t.Fatalf("unexpected error: %s", str)
+ }
+}