mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
24 lines
460 B
JavaScript
24 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;
|