From 042200145fbf994e3fcbfa87e75b10d042867b3a Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Thu, 30 Apr 2015 12:11:35 -0700 Subject: 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 --- src/text/template/exec_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/text/template/exec_test.go') diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go index 8c4e165f2f..27c74eb44d 100644 --- a/src/text/template/exec_test.go +++ b/src/text/template/exec_test.go @@ -1095,3 +1095,16 @@ func TestMissingMapKey(t *testing.T) { 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) + } +} -- cgit v1.3-5-g9baa