Sha256: 0774fcb1e34ac11c024a3a8d3fdf72859ca8c50bbb98bd2000022feac3990826
Contents?: true
Size: 691 Bytes
Versions: 1
Compression:
Stored size: 691 Bytes
Contents
module RailsEmoji class << self def render(text, *args) options = args.extract_options! host = options[:host] || "" size = options[:size] || 20 class_name = options[:class] || "emoji" # Replace text.gsub(/:([^:]+):/) do |emoji| emoji_code = emoji emoji = emoji_code.gsub(":", "") %{<img src="#{ host }/assets/emojis/#{ emoji.gsub('+', 'plus') }.png" } + %{width="#{ size }" height="#{ size }" } + %{title="#{ emoji_code }" alt="#{ emoji_code }" class="#{ class_name }" />} end end end end # extend to String class class String def emoji_to_html RailsEmoji.render(self) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_emoji-1.0 | lib/rails_emoji/render.rb |