Class: RBlade::CompilesComponents

Inherits:
Object
  • Object
show all
Defined in:
lib/rblade/compiler/compiles_components.rb

Instance Method Summary collapse

Constructor Details

#initializeCompilesComponents

Returns a new instance of CompilesComponents.



5
6
7
8
# File 'lib/rblade/compiler/compiles_components.rb', line 5

def initialize
  @component_count = 0
  @component_stack = []
end

Instance Method Details

#compile!(tokens) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rblade/compiler/compiles_components.rb', line 10

def compile!(tokens)
  tokens.each do |token|
    if [:component, :component_start, :component_end, :component_unsafe_end].none? token.type
      next
    end

    token.value = if token.type == :component_start
      compile_token_start token
    elsif token.type == :component_end || token.type == :component_unsafe_end
      compile_token_end token
    else
      compile_token_start(token) + compile_token_end(token)
    end
  end
end