mirror of
https://github.com/flarum/core.git
synced 2025-07-31 21:50:50 +02:00
Hello world!
This commit is contained in:
18
ember/app/helpers/highlight-words.js
Normal file
18
ember/app/helpers/highlight-words.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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);
|
||||
});
|
||||
|
Reference in New Issue
Block a user