Skip to content

Instantly share code, notes, and snippets.

@wlaurance
Forked from ryndel/handlebars.linkify.js
Last active December 16, 2015 19:00
Show Gist options
  • Save wlaurance/5482414 to your computer and use it in GitHub Desktop.
Save wlaurance/5482414 to your computer and use it in GitHub Desktop.
Change for ember
Ember.Handlebars.registerBoundHelper('linkify', function (text) {
text = text.replace(/(https?:\/\/\S+)/gi, function (s) {
return '<a href="' + s + '">' + s + '</a>';
});
text = text.replace(/(^|)@(\w+)/gi, function (s) {
return '<a href="http://twitter.com/' + s + '">' + s + '</a>';
});
text = text.replace(/(^|)#(\w+)/gi, function (s) {
return '<a href="http://search.twitter.com/search?q=' + s.replace(/#/,'%23') + '">' + s + '</a>';
});
return new Handlebars.SafeString(text);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment