Created
April 22, 2019 13:07
-
-
Save kimihito/f9dcf0ab4f97f7e9f0cad9b8ffb7b36b to your computer and use it in GitHub Desktop.
Use autolink twitter-text gem
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
module TrackDecorator | |
include Twitter::TwitterText::Autolink | |
include Rails.application.routes.url_helpers | |
def body | |
# https://github.com/twitter/twitter-text/blob/752b9476d5ed00c2ec60d0a6bb3b34bd5b19bcf9/rb/spec/autolinking_spec.rb#L687-L689 | |
html = auto_link_hashtags(raw_body, { :hashtag_url_block => lambda { |url| project_path(self.project) } , hashtag_class: 'Label Label--gray'}) | |
raw html | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment