mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-04 04:10:33 +03:00
28 lines
573 B
JavaScript
28 lines
573 B
JavaScript
import {helper} from 'ember-helper';
|
|
import {htmlSafe} from 'ember-string';
|
|
|
|
export default helper(function (params) {
|
|
if (!params || params.length < 2) {
|
|
return;
|
|
}
|
|
|
|
let el = document.createElement('span');
|
|
let [content, maxCharacters] = params;
|
|
let length;
|
|
|
|
content = content || '';
|
|
length = content.length;
|
|
|
|
el.className = 'word-count';
|
|
|
|
if (length > maxCharacters) {
|
|
el.style.color = '#E25440';
|
|
} else {
|
|
el.style.color = '#9FBB58';
|
|
}
|
|
|
|
el.innerHTML = length;
|
|
|
|
return htmlSafe(el.outerHTML);
|
|
});
|