Javascript – jTemplate and MicrosoftAjaxTemplates encode or decoded html (browser not render as html)

asp.netjavascriptjtemplate

I using jTemplate for showing rss item in my page. but description of each item not render right.

My Template is:

<table>
  <thead>
    <tr>
      <th>Date</th>
      <th>Title</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    {#foreach $T.Items as post}
    <tr>
      <td>{$T.post.PubDate}</td>
      <td><a href="{$T.post.Link}">{$T.post.Title}</a></td>
      <td>{$T.post.Description}</td>
    </tr>
    {#/for}
  </tbody>
</table>

but when render page, I see tag(or encoded tag) instead of render html in description column:

&lt ;table border=0 width= valign=top
cellpadding=2 cellspacing=7& gt;&
lt;tr& gt;& lt;td width=80
align=center valign=top& gt;& lt;font
style="font-size:85%;font-family:arial,sans-serif"&
gt;….

And when html decode on server side, see:

<table border=0 width= valign=top
cellpadding=2
cellspacing=7><tr><td
width=80 align=center
valign=top><font
style="font-size:85%;font-family:arial,sans-serif">….

What's the problem?

Note: I test with MicrosoftAjaxTemplates and see same problem, but when using with string it's ok like $('.desc').append(' any html tag');

Best Answer

jTemplates escapes HTML by default. You can change that by changing a property on the optional settings object as the third argument like so:

.setTemplate("#template", null, { filter_data: false });