Created
August 2, 2011 23:28
-
-
Save arbales/1121495 to your computer and use it in GitHub Desktop.
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
Endor.Utils.formatLinks = (content) -> | |
safeContent = Handlebars.Utils.escapeExpression(content) | |
safeContent = safeContent.replace LINK_DETECTION_REGEX, (url) -> | |
address = if /[a-z]+:\/\//.test url then url else "http://#{url}" | |
"<a href='#{address}' target='_blank'>#{url}</a>" | |
new Handlebars.SafeString(safeContent) # Mark our string as safe, since it is. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment