Class: Haml::Exec::HTML2Haml
- Defined in:
- lib/gems/haml-2.0.4/lib/haml/exec.rb
Overview
A class encapsulating executable functionality specific to the html2haml executable.
Instance Method Summary collapse
-
#initialize(args) ⇒ HTML2Haml
constructor
:nodoc:.
- #process_result ⇒ Object
- #set_opts(opts) ⇒ Object
Methods inherited from Generic
Constructor Details
#initialize(args) ⇒ HTML2Haml
:nodoc:
276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/gems/haml-2.0.4/lib/haml/exec.rb', line 276 def initialize(args) super @module_opts = {} begin require 'haml/html' rescue LoadError => err dep = err..scan(/^no such file to load -- (.*)/)[0] puts "Required dependency #{dep} not found!" exit 1 end end |
Instance Method Details
#process_result ⇒ Object
314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/gems/haml-2.0.4/lib/haml/exec.rb', line 314 def process_result super input = @options[:input] output = @options[:output] @module_opts[:rhtml] ||= input.respond_to?(:path) && input.path =~ /\.(rhtml|erb)$/ @module_opts[:rhtml] &&= @options[:no_rhtml] != false output.write(::Haml::HTML.new(input, @module_opts).render) end |
#set_opts(opts) ⇒ Object
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/gems/haml-2.0.4/lib/haml/exec.rb', line 290 def set_opts(opts) opts. = <<END Usage: html2haml [options] [INPUT] [OUTPUT] Description: Transforms an HTML file into corresponding Haml code. Options: END opts.on('-r', '--rhtml', 'Parse RHTML tags.') do @module_opts[:rhtml] = true end opts.on('--no-rhtml', "Don't parse RHTML tags.") do @options[:no_rhtml] = true end opts.on('-x', '--xhtml', 'Parse the input using the more strict XHTML parser.') do @module_opts[:xhtml] = true end super end |