问题描述
有什么方法可以在helper中返回innerHTML吗?
我的意思是这样的:
text:function(){
return< p>它正在运作!< / p>
}
这些记录会有更多记录,因为我通过循环{{#each }}循环,我试图通过JQuery来做,但很难命名类/ ID,所以我会很感激,如果有人可以告诉我如何使用帮助器做到这一点
您可以使用Handlebars.SafeString:
text:function(){
返回新的Handlebars.SafeString(< p>它正在运作!< / p>);
}
它会产生安全的HTML字符串。如果您的助手从用户输入中返回某些内容,{{{...}}}不是安全的。{b} {b} {b} > in Meteor 1. *使用SpaceBars而不是Handlebars:
text:function(){
返回新的Spacebars。 SafeString(< p>正在运作!< / p>);
}
is there any way I can return innerHTML in helper?I mean something like this:
text: function(){
return "<p>It's working!</p>"
}
There would be more of those records since I loop them through {{#each}} loop and I tried to do it throught JQuery but had hard times naming classes/ID's so I would appreciate if someone could tell me how to do it with helper
You can use Handlebars.SafeString:
text: function(){
return new Handlebars.SafeString("<p>It's working!</p>");
}
It will produce safe HTML string. Using not escaping with tripple brackets {{{...}}} is not secure if your helper returns something from user's input.
EDIT: in Meteor 1.* use Spacebars instead of Handlebars:
text: function(){
return new Spacebars.SafeString("<p>It's working!</p>");
}
这篇关于Meteor.js在帮助程序中返回innerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!