Meteor 将连接的变量和字符串作为参数传递给模板帮助器
如果我尝试将变量和字符串作为参数传递给模板帮助器,我最终会得到字符串文字:Meteor 将连接的变量和字符串作为参数传递给模板帮助器,meteor,spacebars,Meteor,Spacebars,如果我尝试将变量和字符串作为参数传递给模板帮助器,我最终会得到字符串文字: {{#ContainerSurface class='progressBarContainer {{namespace}}'}} 最终成为 如果我试着去做 {{#ContainerSurface class={{'progressBarContainer ' + namespace}} 我最后犯了一个错误: =>阻止启动的错误: 在构建应用程序时: client/cordova/pages/widgets/progr
{{#ContainerSurface class='progressBarContainer {{namespace}}'}}
最终成为
如果我试着去做
{{#ContainerSurface class={{'progressBarContainer ' + namespace}}
我最后犯了一个错误:
=>阻止启动的错误:
在构建应用程序时:
client/cordova/pages/widgets/progressBar/progressBar.html:2:预期标识符、编号、,
字符串、布尔值或null
…sBarContainer'类={{{'progressBarContai。。。
^
=>您的应用程序有错误。正在等待文件更改
我可以创建一个返回字符串+变量的模板帮助器,但这会导致代码混乱,因为我需要多次这样做。您实际上可以创建一个帮助器,并使用包在其他模板上使用
Template.foo.helpers = function () {
thisHelperIsAvaibleEverywhere:function(){
return "Test";
}
};
Template.foo2.inheritsHelpersFrom("thisHelperIsAvaibleEverywhere");
现在只需声明一个模板助手,并继承到其他模板
Template.foo.helpers = function () {
thisHelperIsAvaibleEverywhere:function(){
return "Test";
}
};
Template.foo2.inheritsHelpersFrom("thisHelperIsAvaibleEverywhere");
其中,foo2表示另一个模板的名称