Class: EachScope

Inherits:
ViewScope show all
Defined in:
lib/volt/server/html_parser/each_scope.rb

Instance Attribute Summary

Attributes inherited from ViewScope

#binding_number, #bindings, #html, #path

Instance Method Summary collapse

Methods inherited from ViewScope

#<<, #add_binding, #add_component, #add_content_binding, #add_each, #add_else, #add_if, #add_template, #add_textarea, #save_binding

Methods included from AttributeScope

#add_id_to_attributes, #add_multiple_attribute, #add_reactive_template, #add_single_attribute, #attribute_string, #process_attribute, #process_attributes, #process_event_binding

Constructor Details

#initialize(handler, path, content) ⇒ EachScope

Returns a new instance of EachScope.



2
3
4
5
# File 'lib/volt/server/html_parser/each_scope.rb', line 2

def initialize(handler, path, content)
  super(handler, path)
  @content, @variable_name = content.strip.split(/ as /)
end

Instance Method Details

#close_scopeObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/volt/server/html_parser/each_scope.rb', line 7

def close_scope
  binding_number = @handler.scope[-2].binding_number
  @handler.scope[-2].binding_number += 1
  @path += "/__template/#{binding_number}"
  
  super
  
  @handler.html << "<!-- $#{binding_number} --><!-- $/#{binding_number} -->"
@handler.scope.last.save_binding(binding_number, "lambda { |__p, __t, __c, __id| EachBinding.new(__p, __t, __c, __id, Proc.new { #{@content} }, #{@variable_name.inspect}, #{@path.inspect}) }")
  
end