Ghost/ghost/admin/helpers/gh-count-words.js
Jason Williams 5ea14118c8 Update Ember to 1.10.0
No issue.
- Ember@1.10.0
- Update grunt-ember-templates to version that supports HTMLBars.
- Update Gruntfile.js to compile templates with HTMLBars.
- Convert Handlebars code to its HTMLBars equivalent.
2015-02-09 16:20:16 +00:00

23 lines
433 B
JavaScript

import counter from 'ghost/utils/word-count';
var countWords = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
if (!arr || !arr.length) {
return;
}
var markdown,
count;
markdown = arr[0] || '';
if (/^\s*$/.test(markdown)) {
return '0 words';
}
count = counter(markdown);
return count + (count === 1 ? ' word' : ' words');
});
export default countWords;