Skip to content

Instantly share code, notes, and snippets.

@kimihito
Created April 22, 2019 13:07
Show Gist options
  • Save kimihito/f9dcf0ab4f97f7e9f0cad9b8ffb7b36b to your computer and use it in GitHub Desktop.
Save kimihito/f9dcf0ab4f97f7e9f0cad9b8ffb7b36b to your computer and use it in GitHub Desktop.
Use autolink twitter-text gem
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