0

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

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

Community
  • 1
  • 1
Nils Ziehn
  • 4,118
  • 6
  • 26
  • 40

1 Answers1

0

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}}
mark pavlis
  • 681
  • 1
  • 5
  • 9