I'm working on a project in Play (+Scala) where after a particular flow, an email is sent.
The email uses a template (e.g. email.scala.html), which contains HTML and inserts data from a "model" (which is really a Map[String, String])
What I find is some text is encoded which I don't want encoded
For example:
<a href="http://madeupsite.com?param1=x¶m2=y">link</a>
Gets encoded like (notice &
gets replaced with &
):
<a href="http://madeupsite.com?param1=x&param2=y">link</a>
This will break the link that gets emailed
How this gets included in the template:
<a href="@emailModel.get("url").get">link</a>
In code:
def prepareEmail(tuple: (Map[String, String], Map[String, String])): HtmlEmail = tuple match {
case (headers, emailBody) if headers.nonEmpty && emailBody.nonEmpty => {
def createMessageFromTemplate(model: Map[String, String]): String = {
views.html.email(model).toString
}
...
This line is the important bit
views.html.email(model).toString
I can't seem to find anything on rendering this without encoding
For example these don't seem to work:
@Html(...)
@TxtFormat.raw(...)
@TxtFormat.raw(...).toString.replace("&", "&")
I'm not a Play/Scala expert, so any help would be much appreciated