Skip to content

Instantly share code, notes, and snippets.

@steverichey
Created April 21, 2015 18:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steverichey/2d8e0869abcc1b38a09f to your computer and use it in GitHub Desktop.
Save steverichey/2d8e0869abcc1b38a09f to your computer and use it in GitHub Desktop.
An Ember helper that prevents user-facing NaN values.
/**
* 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