Sha256: 23ece5ff8e6819f9881181f93c73ff975a4e9e332b565a8b64408a1d6a7e204c

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require "execjs"

module Rasputin
  module Handlebars
    module Source

      def self.precompiler_path
        assets_path("ember-precompiler.js")
      end

      def self.assets_path(name)
        File.expand_path(File.join(__FILE__, "..", "..", "..", "..", "vendor/assets/javascripts/#{name}"))
      end

      def self.bundled_path
        assets_path("ember.js")
      end

      def self.path
        @path ||= ENV["EMBER_SOURCE_PATH"] || bundled_path
      end

      def self.path=(path)
        @contents = @version = @context = nil
        @path = path
      end

      def self.contents
        @contents ||= [File.read(precompiler_path), File.read(path)].join("\n")
      end

      def self.version
        @version ||= contents[/^Handlebars.VERSION = "([^"]*)"/, 1]
      end

      def self.context
        @context ||= ExecJS.compile(contents)
      end
    end

    class << self
      def version
        Source.version
      end

      def compile(template)
        template = template.read if template.respond_to?(:read)
        Source.context.call("EmberHandlebars.precompile", template)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rasputin-0.13.2 lib/rasputin/handlebars/compiler.rb
rasputin-0.13.1 lib/rasputin/handlebars/compiler.rb
rasputin-0.12.1 lib/rasputin/handlebars/compiler.rb