2019-06-26 09:11:04 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module EmojiHelper
|
|
|
|
def emoji_codes_to_img(str)
|
|
|
|
return if str.blank?
|
|
|
|
|
|
|
|
str = str.gsub(/:([\w\-+]*(?::t\d)?):/) do |name|
|
|
|
|
code = $1
|
|
|
|
|
2019-07-03 03:23:40 -04:00
|
|
|
if code && Emoji.custom?(code)
|
|
|
|
emoji = Emoji[code]
|
|
|
|
"<img src=\"#{emoji.url}\" title=\"#{code}\" class=\"emoji\" alt=\"#{code}\">"
|
|
|
|
elsif code && Emoji.exists?(code)
|
2019-06-26 09:11:04 -04:00
|
|
|
"<img src=\"#{Emoji.url_for(code)}\" title=\"#{code}\" class=\"emoji\" alt=\"#{code}\">"
|
|
|
|
else
|
|
|
|
name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
raw(str)
|
|
|
|
end
|
|
|
|
end
|