Created
August 11, 2014 19:19
-
-
Save macu/02804c50ee930dc20246 to your computer and use it in GitHub Desktop.
Ember pluralize 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
| 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