Skip to content

Instantly share code, notes, and snippets.

@AustinW
Created April 18, 2014 20:49
Show Gist options
  • Save AustinW/11063755 to your computer and use it in GitHub Desktop.
Save AustinW/11063755 to your computer and use it in GitHub Desktop.
Ember Math Helper
Ember.Handlebars.helper('math', function(operand1, operator, operand2) {
var result;
switch (operator) {
case '+':
result = operand1 + operand2;
break;
case '-':
result = operand1 - operand2;
break;
case '*':
result = operand1 * operand2;
break;
case '/':
result = operand1 / operand2;
break;
}
return result;
});
@MichalGallovic
Copy link

applicable to handlebars, thx !

@macetti8
Copy link

I need to make a simple division to show 50% or 33% depending of the product discount so basically for example:

``{{math toFixed sell "/" 2}}
but appear just the result of the variable without operation done.

I pasted your code but does not work, accept math infact appear not error on my console, any suggestion please.

thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment