Module: AutoHtml

Extended by:
AutoHtml
Included in:
ActionView::Helpers::TextHelper, AutoHtml, AutoHtmlFor::InstanceMethods
Defined in:
lib/auto_html/base.rb,
lib/auto_html/filter.rb,
lib/auto_html/builder.rb

Defined Under Namespace

Classes: Builder, Filter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_filter(name, &block) ⇒ Object



4
5
6
# File 'lib/auto_html/base.rb', line 4

def self.add_filter(name, &block)
  AutoHtml::Builder.add_filter(name, &block)
end

Instance Method Details

#auto_html(raw, &proc) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/auto_html/base.rb', line 8

def auto_html(raw, &proc)
  return "" if raw.blank?
  builder = Builder.new(raw)
  result = builder.instance_eval(&proc)
  return raw if result.nil?
  result.respond_to?(:html_safe) ? result.html_safe : result
end