Created
September 19, 2013 06:20
-
-
Save BlackPrincess/6619685 to your computer and use it in GitHub Desktop.
Play2 nlbr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.specs2.mutable._ | |
| class HelperSpec extends Specification { | |
| "nlbr" should { | |
| "newline character will be <br />" in { | |
| views.html.helper.nlbr("foo\nbar").toString must contain ("<br />") | |
| views.html.helper.nlbr("foo\r\nbar").toString must contain ("<br />") | |
| views.html.helper.nlbr("foo\rbar").toString must contain ("<br />") | |
| } | |
| "Html should be escaped" in { | |
| views.html.helper.nlbr("<h1>hoge</h1>").toString must not contain ("<h1>") | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @** | |
| * Convert Multi-line text to Html | |
| * | |
| * @param text text | |
| *@ | |
| @(text:String) | |
| @Html(text.split("[\n\r(\r\n)]").toSeq.map(HtmlFormat.escape).mkString("<br />")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment