1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/helpers/gh-count-words.js
2015-03-11 12:37:41 -06:00

23 lines
460 B
JavaScript

import Ember from 'ember';
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;