module ActionView::Helpers::TextHelper

Constants

AUTO_EMOTE_EMOTICONS

Public Instance Methods

auto_emote(text, options={}, &block) click to toggle source
# File lib/auto_emote/helpers.rb, line 12
def auto_emote(text, options={}, &block)
  return ''.html_safe if text.blank?

  sanitize = (options[: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

Private Instance Methods

conditional_sanitize(target, condition) click to toggle source
# File lib/auto_emote/helpers.rb, line 28
def conditional_sanitize(target, condition)
  condition ? sanitize(target) : target
end