Created
July 21, 2017 21:13
-
-
Save finferflu/8eeeff014acec7525f466aa72d0ab560 to your computer and use it in GitHub Desktop.
Pluralise helper for Ember 2.x
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
// app/helpers/pluralise.js | |
import Ember from 'ember' | |
export function pluralise ([number, singular, plural]) { | |
console.log(singular) | |
Ember.assert('{{pluralise}} helper requires at least two arguments, none provided.', number) | |
Ember.assert('{{pluralise}} helper requires at least two arguments, only one provided.', singular) | |
var pluralWord = plural || singular + 's' | |
return (number === 1) ? singular : pluralWord | |
} | |
export default Ember.Helper.helper(pluralise) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment