[2.0] Newline to br with Scala (nl2br)

1,017 views
Skip to first unread message

apakatt

unread,
Mar 21, 2012, 5:54:45 PM3/21/12
to play-fr...@googlegroups.com
Is there a built in way to convert newlines \n to <br /> in Scala-templates? Or what is the best approach to fix this?
I tried to do a simple .replace("\n", "<br />") but the html-tag gets escaped and I do not want to unescape everything, just the <br /> part.

kfer83

unread,
Nov 4, 2012, 4:41:36 PM11/4/12
to play-fr...@googlegroups.com
bump

Mathias Clerc

unread,
Nov 4, 2012, 8:56:42 PM11/4/12
to play-fr...@googlegroups.com
You can use Html(myString.replace("\n", "<br/>")) to prevent the escaping


2012/11/5 kfer83 <kfe...@gmail.com>
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/rMX2rpJX25MJ.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Marconi

unread,
Nov 4, 2012, 9:54:38 PM11/4/12
to play-fr...@googlegroups.com
I just answered it a few hours ago, it is not very wise to use replace that way: https://groups.google.com/forum/?fromgroups=&nomobile=true#!topic/play-framework/HU2x9ce6mLs
Reply all
Reply to author
Forward
0 new messages