Skip to content

Instantly share code, notes, and snippets.

@finferflu
Created July 21, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finferflu/8eeeff014acec7525f466aa72d0ab560 to your computer and use it in GitHub Desktop.
Save finferflu/8eeeff014acec7525f466aa72d0ab560 to your computer and use it in GitHub Desktop.
Pluralise helper for Ember 2.x
// 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