Lux*_*Lux 41 handlebars.js ember.js
我有灰烬财产,其中包括HTML标签(<br />,<strong>,<p>,<span>,和类似的东西).
我怎么能告诉灰烬不要逃避这个文本?是否有来自ember的默认Handlebars助手,还是需要我自己编写?
Raj*_*jat 85
Handlebars HTML-escapes返回的值
{{expression}}.
如果您不希望Handlebars转义值,请使用"triple-stash".
{{{expression}}}
pan*_*atz 16
在Ember.js你可以通过做这个htmlSafe方法,它被添加到String原型,见http://jsfiddle.net/pangratz666/jNAQ6/:
把手:
<script type="text/x-handlebars" >
{{App.html}} - {{App.unescaped}}
</script>?
Run Code Online (Sandbox Code Playgroud)
JavaScript:
App = Ember.Application.create({
html: '<b>bold text</b>',
unescaped: function(){
return this.get('html').htmlSafe();
}.property('html')
});?
Run Code Online (Sandbox Code Playgroud)