Class: Thredded::AtUsers

Inherits:
Object
  • Object
show all
Defined in:
lib/thredded/at_users.rb

Class Method Summary collapse

Class Method Details

.render(content, post, view_context) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/thredded/at_users.rb', line 3

def self.render(content, post, view_context)
  at_names = AtNotificationExtractor.new(content).run

  if at_names.any?
    members = post.readers_from_user_names(at_names)

    members.each do |member|
      member_path = Thredded.user_path(view_context, member)
      content.gsub!(/(@#{member.to_s})\b/i,
                    %(<a href="#{ERB::Util.html_escape member_path}">\\1</a>))
    end
  end

  content
end