Skip to content

Instantly share code, notes, and snippets.

@macu
Created August 11, 2014 19:19
Show Gist options
  • Select an option

  • Save macu/02804c50ee930dc20246 to your computer and use it in GitHub Desktop.

Select an option

Save macu/02804c50ee930dc20246 to your computer and use it in GitHub Desktop.
Ember pluralize helper
import { Handlebars } from 'ember';
// Thanks for the inspiration: https://coderwall.com/p/ryo_3w
Handlebars.registerBoundHelper('pluralize', function(number, options) {
var phrase = options.hash.phrase || '{|s}';
return phrase.replace(/\{(.*?)\|(.*?)\}/, function(match, singular, plural) {
return number == 1 ? singular : plural;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment