class MultipartErb::Formatter

Public Class Methods

lookup(child, formatter) click to toggle source
# File lib/multiparterb/formatter.rb, line 25
def self.lookup(child, formatter)
  return child.text if child.name == 'text'
  parsed_text = parse(child, formatter).html_safe

  if SUPPORTED_TAG_METHODS.keys.include?(child.name)
    if child.name == 'a'
      formatter.public_send(SUPPORTED_TAG_METHODS[child.name], parsed_text, child.attributes['href'].content)
    else
      formatter.public_send(SUPPORTED_TAG_METHODS[child.name], parsed_text)
    end
  else
    parsed_text
  end
end
parse(node, formatter) click to toggle source
# File lib/multiparterb/formatter.rb, line 17
def self.parse(node, formatter)
  "".tap do |result|
    node.children.each do |child|
      result << lookup(child, formatter)
    end
  end
end
to_html(compiled_source) click to toggle source
# File lib/multiparterb/formatter.rb, line 40
def self.to_html(compiled_source)
  html_doc = Nokogiri::HTML compiled_source
  parse html_doc, MultipartErb.html_formatter
end
to_text(compiled_source) click to toggle source
# File lib/multiparterb/formatter.rb, line 45
def self.to_text(compiled_source)
  html_doc = Nokogiri::HTML compiled_source
  parse html_doc, MultipartErb.text_formatter
end