Ghost/ghost/admin/app/helpers/highlighted-text.js

9 lines
286 B
JavaScript

import {helper} from 'ember-helper';
import {htmlSafe} from 'ember-string';
export function highlightedText([text, termToHighlight]) {
return htmlSafe(text.replace(new RegExp(termToHighlight, 'ig'), '<span class="highlight">$&</span>'));
}
export default helper(highlightedText);