Search code examples
backbone.jsbackbone-views

backbone js print variable value in view which is an html


I am very new to backbone.js and learning it. I managed to pass my variables to the view and they are being displayed fine. What I am struggling with is what if the variable being passed to the view is an html that looks like this <p>I am an html print me on view</p> now suppose this variable is called description so inside the view if I do

<%-description %>

This actually displays the result in html as you can see in the following screenshot. So my question is how can i print a variable on view which is an html?

Any help will be greatly appreciated.

enter image description here


Solution

  • Have a look at _.template doc, it says

    Template functions can both interpolate values, using <%= … %> [...] If you wish to interpolate a value, and have it be HTML-escaped, use <%- … %>

    Use <%= description %> to insert the raw, unescaped HTML.