In Files

Haml::Exec::HTML2Haml

The `html2haml` executable.

Public Class Methods

new(args) click to toggle source

@param args [Array] The command-line arguments

     # File lib/haml/exec.rb, line 300
300:       def initialize(args)
301:         super
302:         @module_opts = {}
303:       end

Public Instance Methods

process_result() click to toggle source

Processes the options set by the command-line arguments, and runs the HTML compiler appropriately.

     # File lib/haml/exec.rb, line 342
342:       def process_result
343:         super
344: 
345:         require 'haml/html'
346: 
347:         input = @options[:input]
348:         output = @options[:output]
349: 
350:         @module_opts[:erb] ||= input.respond_to?(:path) && input.path =~ /\.(rhtml|erb)$/
351:         @module_opts[:erb] &&= @options[:no_erb] != false
352: 
353:         output.write(::Haml::HTML.new(input, @module_opts).render)
354:       rescue ::Haml::Error => e
355:         raise "#{e.is_a?(::Haml::SyntaxError) ? "Syntax error" : "Error"} on line " +
356:           "#{get_line e}: #{e.message}"
357:       rescue LoadError => err
358:         handle_load_error(err)
359:       end
set_opts(opts) click to toggle source

Tells optparse how to parse the arguments.

@param opts [OptionParser]

     # File lib/haml/exec.rb, line 308
308:       def set_opts(opts)
309:         opts.banner = Usage: html2haml [options] [INPUT] [OUTPUT]Description: Transforms an HTML file into corresponding Haml code.Options:
310: 
311:         opts.on('-e', '--erb', 'Parse ERb tags.') do
312:           @module_opts[:erb] = true
313:         end
314: 
315:         opts.on('--no-erb', "Don't parse ERb tags.") do
316:           @options[:no_erb] = true
317:         end
318: 
319:         opts.on('-r', '--rhtml', 'Deprecated; same as --erb.') do
320:           @module_opts[:erb] = true
321:         end
322: 
323:         opts.on('--no-rhtml', "Deprecated; same as --no-erb.") do
324:           @options[:no_erb] = true
325:         end
326: 
327:         opts.on('-x', '--xhtml', 'Parse the input using the more strict XHTML parser.') do
328:           @module_opts[:xhtml] = true
329:         end
330: 
331:         super
332:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.