Class: RBlade::CompilesComponents

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

Instance Method Summary collapse

Constructor Details

#initialize(component_store) ⇒ CompilesComponents

Returns a new instance of CompilesComponents.



7
8
9
10
11
# File 'lib/rblade/compiler/compiles_components.rb', line 7

def initialize(component_store)
  @component_count = 0
  @component_stack = []
  @component_store = component_store
end

Instance Method Details

#compile!(tokens) ⇒ Object



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

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

#ensure_all_tags_closedObject



29
30
31
32
33
# File 'lib/rblade/compiler/compiles_components.rb', line 29

def ensure_all_tags_closed
  unless @component_stack.empty?
    raise RBladeTemplateError.new("Unexpected end of document. Expecting </x-#{@component_stack.last[:name]}>")
  end
end