class Haml::HTML
#=> “%a{:href => ‘google.com’} Blat”
Haml::HTML.new(“<a href=‘google.com’>Blat</a>”).render
Example usage:
and [ruby_parser](parsetree.rubyforge.org/) to parse the Ruby code.<br>(www.kuwata-lab.com/erubis) to parse the ERB
If ERB conversion is being used, also depends on
Depends on [Hpricot](github.com/whymirror/hpricot) for HTML parsing.
Converts HTML documents into Haml templates.
def initialize(template, options = {})
(**options)
-
:xhtml
(Boolean
) -- Whether or not to parse -
:erb
(Boolean
) -- Whether or not to parse
Parameters:
-
template
(String, Hpricot::Node
) -- The HTML template to convert
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
def render
Processes the document and returns the result as a string
def render @template.to_haml(0, @options) end