Sha256: 963c5d4a63557cad733767c2ea1cf54f1b612216efa8422014fca55fd5826b81

Contents?: true

Size: 839 Bytes

Versions: 13

Compression:

Stored size: 839 Bytes

Contents

module Volt
  class EachScope < ViewScope
    def initialize(handler, path, content)
      super(handler, path)
      # @content, @variable_name = content.strip.split(/ as /)

      @content, @variable_name = content.split(/.each\s+do\s+\|/)

      @variable_name = @variable_name.gsub(/\|/, '')
    end

    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| Volt::EachBinding.new(__p, __t, __c, __id, Proc.new { #{@content} }, #{@variable_name.inspect}, #{@path.inspect}) }")
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
volt-0.8.26 lib/volt/server/html_parser/each_scope.rb
volt-0.8.24 lib/volt/server/html_parser/each_scope.rb
volt-0.8.23 lib/volt/server/html_parser/each_scope.rb
volt-0.8.22 lib/volt/server/html_parser/each_scope.rb
volt-0.8.22.beta2 lib/volt/server/html_parser/each_scope.rb
volt-0.8.22.beta1 lib/volt/server/html_parser/each_scope.rb
volt-0.8.21 lib/volt/server/html_parser/each_scope.rb
volt-0.8.20 lib/volt/server/html_parser/each_scope.rb
volt-0.8.19 lib/volt/server/html_parser/each_scope.rb
volt-0.8.18 lib/volt/server/html_parser/each_scope.rb
volt-0.8.17 lib/volt/server/html_parser/each_scope.rb
volt-0.8.16 lib/volt/server/html_parser/each_scope.rb
volt-0.8.15 lib/volt/server/html_parser/each_scope.rb