Sha256: e8764e6d07bf12380a54e027b5fd1dcd9025c37555cad7172fb2d93493e07021

Contents?: true

Size: 579 Bytes

Versions: 1

Compression:

Stored size: 579 Bytes

Contents

require 'rumoji'
require 'emoji'

module Emojionearea
  module Rails
    module Helper
      def gemojify(content)
        text_symbol = Rumoji.encode(content)
        text_symbol.gsub(/:([\w+-]+):/) do |match|
          if emoji = Emoji.find_by_alias($1)
            %(<img alt="#{emoji.raw}" src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/png/#{emoji.image_filename.split("/").last}" style="vertical-align:middle" width="16" height="16" />)
          else
            match
          end
        end.html_safe if content.present?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emojionearea-rails-1.0.0 lib/emojionearea/rails/helper.rb