# Class: Haml::Compiler

Inherits:
  Object
  - Object
  - Haml::Compiler
  show all

Includes:
  Util

Defined in:
  lib/haml/compiler.rb

## Instance Attribute Summary collapse

- #options

  Returns the value of attribute options.

## Instance Method Summary collapse

- #call(node)
- #compile(node)
- #initialize(options) ⇒ Compiler constructor

  A new instance of Compiler.

### 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.

    13
    14
    15
    16
    17
    18
    19
    20

    # File 'lib/haml/compiler.rb', line 13

    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.

    11
    12
    13

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

    def options
      @options
    end

## Instance Method Details

### #call(node)

    22
    23
    24
    25

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

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

### #compile(node)

    27
    28
    29
    30
    31
    32
    33
    34
    35
    36

    # File 'lib/haml/compiler.rb', line 27

    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