lib/handlebars/context.rb in handlebars-0.5.0 vs lib/handlebars/context.rb in handlebars-0.6.0
- old
+ new
@@ -1,15 +1,13 @@
require 'handlebars/source'
-require 'commonjs'
require 'v8'
module Handlebars
class Context
def initialize
- @js = CommonJS::Environment.new V8::Context.new, :path => [
- File.dirname(Handlebars::Source.bundled_path)
- ]
+ @js = V8::Context.new
+ @js.load(Handlebars::Source.bundled_path)
@partials = handlebars.partials = Handlebars::Partials.new
end
def compile(*args)
@@ -31,17 +29,13 @@
def partial_missing(&fn)
@partials.partial_missing = fn
end
def handlebars
- @js.require('handlebars')
+ @js.eval('Handlebars')
end
- def runtime
- @js.runtime
- end
-
def []=(key, value)
data[key] = value
end
def [](key)
@@ -53,9 +47,9 @@
end
private
def data
- handlebars[:_rubydata] ||= @js.new_object
+ handlebars[:_rubydata] ||= handlebars.create()
end
end
end