mirror of
https://github.com/flarum/framework.git
synced 2024-12-06 09:33:37 +08:00
19 lines
531 B
JavaScript
19 lines
531 B
JavaScript
import Ember from 'ember';
|
|
|
|
export default Ember.Handlebars.makeBoundHelper(function(text, phrase, options) {
|
|
if (phrase) {
|
|
var words = phrase.split(' ');
|
|
var replacement = function(matched) {
|
|
return '<span class="highlight-keyword">'+matched+'</span>';
|
|
};
|
|
words.forEach(function(word) {
|
|
text = text.replace(
|
|
new RegExp("\\b"+word+"\\b", 'gi'),
|
|
replacement
|
|
);
|
|
});
|
|
}
|
|
return new Handlebars.SafeString(text);
|
|
});
|
|
|