Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 将连接的变量和字符串作为参数传递给模板帮助器_Meteor_Spacebars - Fatal编程技术网

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表示另一个模板的名称