gpt4 book ai didi

asp.net - jTemplate 和 MicrosoftAjaxTemplates 编码或解码 html(浏览器不呈现为 html)

转载 作者:行者123 更新时间:2023-11-29 15:06:16 24 4
gpt4 key购买 nike

我使用 jTemplate 在我的页面中显示 rss 项目。但每个项目的描述不正确。

我的模板是:

<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>

但是当呈现页面时,我在描述栏中看到标签(或编码标签)而不是呈现 html:

&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;....

当在服务器端进行 html 解码时,请参阅:

<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">....

有什么问题?

注意:我使用 MicrosoftAjaxTemplates 进行测试并看到同样的问题,但是当使用字符串时它没问题 $('.desc').append(' any html tag');

最佳答案

jTemplates 默认转义 HTML。您可以通过更改 optional settings object 上的属性来更改它作为第三个参数:

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

关于asp.net - jTemplate 和 MicrosoftAjaxTemplates 编码或解码 html(浏览器不呈现为 html),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2123733/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com