Search code examples
htmlbackbone.jsunderscore.jsunderscore.js-templating

Backbone template render html content


i have a code something like below which from the server side returns something like this e.g sometext1 <span class='boldclass'> somespantext </span> sometext2

so can any one tell me the best way to display this text as 'sometext1 somespantext sometext2' and not something like sometext1 <span class='boldclass'> somespantext </span> sometext2 ??

Backbone underscore template

<%- item.value %>

Solution

  • From the fine manual:

    template _.template(templateString, [settings])

    [...] If you wish to interpolate a value, and have it be HTML-escaped, use <%- … %>

    You're using <%- ... %> for item.value and <%- HTML encodes. If item.value contains HTML that you want on the page then just use <%= ... %>:

    <%= item.value %>