Converts HTML documents into Haml templates. Depends on [Hpricot](github.com/whymirror/hpricot) for HTML parsing. If ERB conversion is being used, also depends on [Erubis](www.kuwata-lab.com/erubis) to parse the ERB and [ruby_parser](parsetree.rubyforge.org/) to parse the Ruby code.
Example usage:
Haml::HTML.new("<a href='http://google.com'>Blat</a>").render #=> "%a{:href => 'http://google.com'} Blat"
@param template [String, Hpricot::Node] The HTML template to convert @option options :erb [Boolean] (false) Whether or not to parse
ERB's `<%= %>` and `<% %>` into Haml's `=` and `-`
@option options :xhtml [Boolean] (false) Whether or not to parse
the HTML strictly as XHTML
# File lib/haml/html.rb, line 121 def initialize(template, options = {}) @options = options if template.is_a? Hpricot::Node @template = template else if template.is_a? IO template = template.read end template = Haml::Util.check_encoding(template) {|msg, line| raise Haml::Error.new(msg, line)} if @options[:erb] require 'haml/html/erb' template = ERB.compile(template) end method = @options[:xhtml] ? Hpricot.method(:XML) : method(:Hpricot) @template = method.call(template.gsub('&', '&')) end end