Skip to content

Instantly share code, notes, and snippets.

@catc
Created March 3, 2016 13:55
Show Gist options
  • Save catc/d25787b6b0b3fcf7a27e to your computer and use it in GitHub Desktop.
Save catc/d25787b6b0b3fcf7a27e to your computer and use it in GitHub Desktop.
A helper that exposes Ember.String methods as a template helper
import Ember from 'ember';
const { String: EmberString, Helper: { helper } } = Ember;
/**
* Exposes Ember.String functions as template helpers
*
* @method stringFormatter
* @param {String} str
* @param {String} strMethod
* @return {String} Returns result of desired Ember.String method
*/
export function stringFormatter([str], { strMethod }) {
return EmberString[`${strMethod}`](str);
}
export default helper(stringFormatter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment