I've had in my Meteor project handlebar helper:
Handlebars.registerHelper('isEq', function(v1, v2, options){
if(v1 === v2){
return options.fn(this);
}else{
return options.inverse(this);
}
});
But after update to 0.8 and switch from handlebars to spacebars it is not working anymore - I've found in other stackoverflow topic that now I should change Handlebars.registerHelper
to UI.registerHelper
but it is still not working - anyone know how to implement this properly for spacebars?
I use a
UI.registerHelper
to add aneq
function that can be used in conjunction with{{#if}}
inSpacebars
.In the JavaScript code, I register an
eq
function of two variables that I can call fromSpacebars
(the system that has replaced Handlebars in Meteor v0.8)In the HTML, I write:
You want to use it like the following?
From 0.8, block helpers are defined as templates. See https://github.com/meteor/meteor/tree/devel/packages/spacebars#custom-block-helpers
And I think you need to call it with keyword arguments (
{{#isEq v1=7 v2=8}}
). Although, you should be able to defineisEq
as an helper, and then use the#if
block helper like{{#if isEq 7 8}}
.This is how I implemented in Meteor 1.3+