-
-
Save wlaurance/5482414 to your computer and use it in GitHub Desktop.
Change for ember
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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