Class: Haml::Compiler::ChildrenCompiler

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

Instance Method Summary collapse

Constructor Details

#initializeChildrenCompiler

Returns a new instance of ChildrenCompiler.



7
8
9
10
# File 'lib/haml/compiler/children_compiler.rb', line 7

def initialize
  @lineno = 1
  @multi_flattener = Temple::Filters::MultiFlattener.new
end

Instance Method Details

#compile(node, &block)



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/haml/compiler/children_compiler.rb', line 12

def compile(node, &block)
  temple = [:multi]
  return temple if node.children.empty?

  temple << [:whitespace] if prepend_whitespace?(node)
  node.children.each do |n|
    rstrip_whitespace!(temple) if nuke_prev_whitespace?(n)
    insert_newlines!(temple, n)
    temple << moving_lineno(n) { block.call(n) }
    temple << [:whitespace] if insert_whitespace?(n)
  end
  rstrip_whitespace!(temple) if nuke_inner_whitespace?(node)
  temple
end