class Haml::Exec::HTML2Haml
:nodoc:
specific to the html2haml executable.
A class encapsulating executable functionality
def initialize(args)
specific to the html2haml executable.
A class encapsulating executable functionality
def initialize(args) super @module_opts = {} begin require 'haml/html' rescue LoadError => err dep = err.message.scan(/^no such file to load -- (.*)/)[0] puts "Required dependency #{dep} not found!" exit 1 end end
def process_result
def process_result super input = @options[:input] output = @options[:output] output.write(::Haml::HTML.new(input, @module_opts).render) end
def set_opts(opts)
def set_opts(opts) opts.banner = <<END html2haml [options] [INPUT] [OUTPUT] ption: Transforms an HTML file into corresponding Haml code. s: opts.on('-r', '--rhtml', 'Parse RHTML tags.') do @module_opts[:rhtml] = true end opts.on('-x', '--xhtml', 'Parse the input using the more strict XHTML parser.') do @module_opts[:xhtml] = true end super end