From 15701879954c19cdd0eb494a49b458d200089f82 Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Tue, 20 Feb 2018 21:47:39 +0100 Subject: [PATCH] newLine at end of @this(...) and @(...) are not part of content --- .../src/main/scala/play/twirl/parser/TwirlParser.scala | 9 +++++++-- .../twirl/compile/src/test/scala/test/Test.scala | 4 ++-- .../twirl/scalajs-compile/src/main/scala/Test.scala | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/parser/src/main/scala/play/twirl/parser/TwirlParser.scala b/parser/src/main/scala/play/twirl/parser/TwirlParser.scala index 903b6a3a..1d8d5f0d 100644 --- a/parser/src/main/scala/play/twirl/parser/TwirlParser.scala +++ b/parser/src/main/scala/play/twirl/parser/TwirlParser.scala @@ -902,8 +902,13 @@ class TwirlParser(val shouldParseInclusiveDot: Boolean) { input.regress(1) val p = input.offset() val args = templateArgs() - if (args != null) Some(position(PosString(args), p)) - else None + if (args != null) { + val result = position(PosString(args), p) + check("\n") + Some(result) + } else { + None + } } else None } diff --git a/sbt-twirl/src/sbt-test/twirl/compile/src/test/scala/test/Test.scala b/sbt-twirl/src/sbt-test/twirl/compile/src/test/scala/test/Test.scala index fb6b8cdd..24c31da3 100644 --- a/sbt-twirl/src/sbt-test/twirl/compile/src/test/scala/test/Test.scala +++ b/sbt-twirl/src/sbt-test/twirl/compile/src/test/scala/test/Test.scala @@ -7,7 +7,7 @@ object Test extends App { assert(template.body == expected, s"Found '$template' but expected '$expected'") } - test(a.b.html.c.render("world"), "\nHello, world.\n") + test(a.b.html.c.render("world"), "Hello, world.\n") - test(html.template.render("42"), "\nAnswer: 42\n") + test(html.template.render("42"), "Answer: 42\n") } diff --git a/sbt-twirl/src/sbt-test/twirl/scalajs-compile/src/main/scala/Test.scala b/sbt-twirl/src/sbt-test/twirl/scalajs-compile/src/main/scala/Test.scala index 174551d3..a4cc16f4 100644 --- a/sbt-twirl/src/sbt-test/twirl/scalajs-compile/src/main/scala/Test.scala +++ b/sbt-twirl/src/sbt-test/twirl/scalajs-compile/src/main/scala/Test.scala @@ -6,7 +6,7 @@ object Test extends App { assert(template.body == expected, s"Found '$template' but expected '$expected'") } - test(a.b.html.c.render("world"), "\nHello, world.\n") + test(a.b.html.c.render("world"), "Hello, world.\n") - test(html.template.render("42"), "\nAnswer: 42\n") + test(html.template.render("42"), "Answer: 42\n") }