Skip to content

Instantly share code, notes, and snippets.

@lamalex
Created May 19, 2013 16:51
Show Gist options
  • Save lamalex/5608227 to your computer and use it in GitHub Desktop.
Save lamalex/5608227 to your computer and use it in GitHub Desktop.
Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
break;
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
break;
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
break;
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
break;
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
break;
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
break;
default:
return options.inverse(this)
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment