Module: Less::JavaScript

Defined in:
lib/less/java_script.rb,
lib/less/java_script/v8_context.rb,
lib/less/java_script/rhino_context.rb

Defined Under Namespace

Classes: RhinoContext, V8Context

Constant Summary collapse

@@context_wrapper =
nil

Class Method Summary collapse

Class Method Details

.context_wrapperObject



16
17
18
# File 'lib/less/java_script.rb', line 16

def self.context_wrapper
  @@context_wrapper ||= default_context_wrapper
end

.context_wrapper=(klass) ⇒ Object



20
21
22
# File 'lib/less/java_script.rb', line 20

def self.context_wrapper=(klass)
  @@context_wrapper = klass
end

.default_context_wrapperObject



4
5
6
7
8
9
10
11
12
# File 'lib/less/java_script.rb', line 4

def self.default_context_wrapper
  if defined?(JRUBY_VERSION)
    require 'less/java_script/rhino_context'
    RhinoContext
  else
    require 'less/java_script/v8_context'
    V8Context
  end
end

.eval(source) ⇒ Object



29
30
31
# File 'lib/less/java_script.rb', line 29

def self.eval(source)
  context_wrapper.instance.eval(source)
end

.exec(&block) ⇒ Object

execute a block as JS



25
26
27
# File 'lib/less/java_script.rb', line 25

def self.exec(&block)
  context_wrapper.instance.exec(&block)
end