Sha256: 4b5d059c22aed024e838f55b692fe39590dc2f97828be928dc4e693bd0e6eb44

Contents?: true

Size: 535 Bytes

Versions: 4

Compression:

Stored size: 535 Bytes

Contents

# frozen_string_literal: true
module Thredded
  class AtUsers
    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thredded-0.4.0 lib/thredded/at_users.rb
thredded-0.3.2 lib/thredded/at_users.rb
thredded-0.3.1 lib/thredded/at_users.rb
thredded-0.3.0 lib/thredded/at_users.rb