Created
April 18, 2014 20:49
-
-
Save AustinW/11063755 to your computer and use it in GitHub Desktop.
Ember Math Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); |
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
applicable to handlebars, thx !