Module: ActionView::Helpers::TextHelper
- Defined in:
- lib/auto_emote/helpers.rb
Constant Summary collapse
- AUTO_EMOTE_EMOTICONS =
{ ':)' => 'happy', ':(' => 'sad' , ';)' => 'winking' }
Instance Method Summary collapse
Instance Method Details
#auto_emote(text, options = {}, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/auto_emote/helpers.rb', line 12 def auto_emote(text, ={}, &block) return ''.html_safe if text.blank? sanitize = ([:sanitize] != false) text = conditional_sanitize(text, sanitize).to_str AUTO_EMOTE_EMOTICONS.keys.each do |emoticon| puts emoticon s = Regexp.escape(emoticon) text.gsub!(/#{s}/, image_tag(File.join('auto_emote', AUTO_EMOTE_EMOTICONS[emoticon] + '.gif'))) end text end |