I have a problem with my templates, when I return HTML, it's encoded by default, and I cannot find a way to "fix" it.
I want to replace NewLines (\u000a
) with a straight <br />
, but I always end up with &lt;br&gt
;
I've tried to fix it with this function:
function cleanNewLines(text)
{
return $("<div>" + text.replace(/\u000a/ig, "<br />") + "</div>").html();
}
But without any luck.
I call bind the template with: {{cleanNewLines(NoteText)}}
What I am trying to accomplish is the ability to render HTML with client-side templates, so if my database contains newlines, I want to be able to replace them with a <br />
-tag
So if my database contains the string Hi\u000aThis is a test
, I want to replace the \u000a
with a <br />
, so that the string would be Hi<br />This is a test