如何在jQuery.tmpl()中将HTML呈现为呈现的HTML? [英] How to render HTML as rendered HTML in jQuery.tmpl()?
本文介绍了如何在jQuery.tmpl()中将HTML呈现为呈现的HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使用jQuery.tmpl()正确分配HTML.如果我将某物的值作为html标记传递,则它呈现为原样,而不是页面上呈现的HTML标记
I can't assign HTML properly using jQuery.tmpl(). If i pass value of something as html tag it is rendered as as it is instead of HTML tags rendered on page
<div id="window">
<script id="lines" type="text/x-jquery-tmpl">
<div id="${id}" class="line ${type}"><span>${name}</span>: ${body}</div>
</script>
</div>
var line = {
name: 'John',
body: '<strong>hello</strong>
};
$('#lines').tmpl(line).appendTo('#window');
推荐答案
您可以使用{{html body}}
包装模板变量,以覆盖默认的编码行为.
You can wrap the template variable with {{html body}}
to override the default encoding behavior.
这篇关于如何在jQuery.tmpl()中将HTML呈现为呈现的HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文