Method: HTML::Pipeline::MentionFilter#mention_link_filter
- Defined in:
- lib/html/pipeline/@mention_filter.rb
#mention_link_filter(text, base_url = '/', info_url = nil) ⇒ Object
Replace user @mentions in text with links to the mentioned user’s profile page.
text - String text to replace @mention usernames in. base_url - The base URL used to construct user profile URLs. info_url - The “more info” URL used to link to more info on @mentions.
If nil we don't link @mention or @mentioned.
Returns a string with @mentions replaced with links. All links have a ‘user-mention’ class name attached for styling.
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/html/pipeline/@mention_filter.rb', line 92 def mention_link_filter(text, base_url='/', info_url=nil) self.class.mentioned_logins_in(text) do |match, login, is_mentioned| link = if is_mentioned link_to_mention_info(login, info_url) else link_to_mentioned_user(login) end link ? match.sub("@#{login}", link) : match end end |