[英]meteor create custom 'if/else'
I haven't used meteor for a while, back in the day I was able to create custom handlebars helpers like 我有一段时间没有使用流星了,那天我能够创建自定义的车把助手
{{#ifCond this.a "a"}}
...
{{else}}
...
{{/ifCond}}
and define a helper like this: 并定义一个这样的助手:
Handlebars.registerHelper('ifCond', function(v1, v2, options) {
if(v1 === v2) {
return options.fn(this);
}
return options.inverse(this);
});
Example from this SO Question: Stackoverflow Question 该SO问题的示例: Stackoverflow问题
Since meteor introduced new spacebars features this doesn't seem to work anymore, anybody any ideas? 自从流星引入了新的空格键功能以来,这似乎不再有效,有人有想法吗?
I think it has something to do with this: "Custom Block Helpers" : Spacebars docu 我认为这与以下内容有关:“ Custom Block Helpers”: 空格键文件
This was the closest I could get, but it's not too bad: 这是我能得到的最接近的,但还不错:
Handlebars.registerHelper('ifCond', function(v1, v2, options) {
if(v1 === v2) {
return true;
}
return false;
});
{{#if ifCond this.Equipment '==' 'Assistive'}}
true
{{else}}
false
{{/if}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.