Class: Haml::Compiler

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/haml/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#balance, #check_encoding, #check_haml_encoding, #contains_interpolation?, #handle_interpolation, #html_safe, #human_indentation, #inspect_obj, #rails_xss_safe?, #silence_warnings, #unescape_interpolation

Constructor Details

#initialize(options) ⇒ Compiler

Returns a new instance of Compiler



12
13
14
15
16
17
18
19
# File 'lib/haml/compiler.rb', line 12

def initialize(options)
  @options     = Options.wrap(options)
  @to_merge    = []
  @temple      = [:multi]
  @node        = nil
  @filters     = Filters.defined.merge(options[:filters])
  @attribute_compiler = AttributeCompiler.new(@options)
end

Instance Attribute Details

#options

Returns the value of attribute options



10
11
12
# File 'lib/haml/compiler.rb', line 10

def options
  @options
end

Instance Method Details

#call(node)



21
22
23
24
# File 'lib/haml/compiler.rb', line 21

def call(node)
  compile(node)
  @temple
end

#compile(node)



26
27
28
29
30
31
32
33
34
35
# File 'lib/haml/compiler.rb', line 26

def compile(node)
  parent, @node = @node, node
  if node.children.empty?
    send(:"compile_#{node.type}")
  else
    send(:"compile_#{node.type}") {node.children.each {|c| compile c}}
  end
ensure
  @node = parent
end