Created
April 21, 2015 18:15
-
-
Save steverichey/2d8e0869abcc1b38a09f to your computer and use it in GitHub Desktop.
An Ember helper that prevents user-facing NaN values.
This file contains 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
/** | |
* Prevents displaying NaN to the user. Defaults to 0. | |
*/ | |
Ember.Handlebars.helper("safefloat", function(value, options) { | |
if (Ember.isEmpty(value) || isNaN(value)) { | |
value = 0; | |
} | |
return new Ember.Handlebars.SafeString(value); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment