I am working on a simple blog application using MVC 4 and the new WebAPI. I am also using ICanHaz.js for the rendering of the results returned from the webAPI methods I have created. I have been able to get the rendering to work, but the actual text of the comment is in HTML, so the JSON that is returned from the webAPI method looks like this:
{"Title":"just a small title",
"Body":"<p>blah blah blah</p><p>blah blah <strong>blah</strong></p>"}
my template looks like this.
<article>
<h2><a href="#" onclick="GetSingePost({{Id}})">{{ Title }}</a></h2>
{{ Body }}
</article>
How do I get the HTML from the JSON object to actually get rendered as HTML? I have tried the triple brackets:
{{{ Body }}}
That didn't work. Any suggestions would be super helpful.
You could just use JQuery to set the html to an element you have in the template.
<article>
<h2><a href="#" onclick="GetSingePost({{Id}})">{{ Title }}</a></h2>
<div class="content"></div>
</article>
var data = {
first_name: "Henrik",
last_name: "Joreteg",
html : "<h1>Hello</h1>"
}
// I can has user??
html = ich.user(data)
$(html).find('.content').html(data.html);
Not ideal but will work.