Sha256: 18b7ed497b37a82b610706aa078ff43ca02c490187b2e6c41e0dfee0080ab32c

Contents?: true

Size: 1.15 KB

Versions: 55

Compression:

Stored size: 1.15 KB

Contents

# Template parsing is fairly simple at the moment.  Basically we walk the dom and
# do two types of replacements.
# 1) replacement in text nodes
# 2) attribute replacements

class Scope
  attr_accessor :bindings, :outer_binding_number, :closed_block_scopes, :last_if_binding

  def initialize(outer_binding_number=nil)
    # For block bindings, the outer binding number lets us know what the name
    # of the comments are that go before/after this scope block.
    @outer_binding_number = outer_binding_number
    @bindings = {}
  end

  def add_closed_child_scope(scope)
    @closed_block_scopes ||= []
    @closed_block_scopes << scope
  end

  def add_binding(binding_name, setup_code)
    @bindings[binding_name] ||= []
    @bindings[binding_name] << setup_code
  end
  
  def start_if_binding(binding_name, if_binding_setup)
    @last_if_binding = [binding_name, if_binding_setup]
  end
  
  def current_if_binding
    @last_if_binding
  end
  
  def close_if_binding!
    if @last_if_binding
      binding_name, if_binding_setup = @last_if_binding
      @last_if_binding = nil
      
      add_binding(binding_name, if_binding_setup.to_setup_code)
    end
  end
  
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
volt-0.6.5 lib/volt/server/scope.rb
volt-0.6.4 lib/volt/server/scope.rb
volt-0.6.3 lib/volt/server/scope.rb
volt-0.6.2 lib/volt/server/scope.rb
volt-0.6.1 lib/volt/server/scope.rb
volt-0.6.0 lib/volt/server/scope.rb
volt-0.5.18 lib/volt/server/scope.rb
volt-0.5.17 lib/volt/server/scope.rb
volt-0.5.16 lib/volt/server/scope.rb
volt-0.5.15 lib/volt/server/scope.rb
volt-0.5.14 lib/volt/server/scope.rb
volt-0.5.13 lib/volt/server/scope.rb
volt-0.5.12 lib/volt/server/scope.rb
volt-0.5.11 lib/volt/server/scope.rb
volt-0.5.10 lib/volt/server/scope.rb
volt-0.5.9 lib/volt/server/scope.rb
volt-0.5.8 lib/volt/server/scope.rb
volt-0.5.7 lib/volt/server/scope.rb
volt-0.5.6 lib/volt/server/scope.rb
volt-0.5.4 lib/volt/server/scope.rb