Sha256: 612e7aecc7311bf4c823ac06cdca3b18feda5834a398a9930bb0f97d349bc44d

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

require 'volt/server/html_parser/sandlebars_parser'
require 'volt/server/html_parser/view_scope'
require 'volt/server/html_parser/if_view_scope'
require 'volt/server/html_parser/view_handler'
require 'volt/server/html_parser/each_scope'
require 'volt/server/html_parser/textarea_scope'

module Volt
  class ViewParser
    attr_reader :templates

    def initialize(html, template_path)
      @template_path = template_path

      handler = ViewHandler.new(template_path)

      SandlebarsParser.new(html, handler)

      # Close out the last scope
      handler.scope.last.close_scope

      @templates = handler.templates
    end

    # Returns a parsed version of the data (useful for backend rendering
    # and testing)
    def data
      templates = @templates.deep_clone

      templates.each_pair do |name, value|
        if value['bindings']
          value['bindings'].each_pair do |number, binding|
            value['bindings'][number] = binding.map { |code| eval(code) }
          end
        end
      end

      templates
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

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