Class: Haml::More::CoffeeScript::JohnsonCompiler

Inherits:
Compiler
  • Object
show all
Defined in:
lib/haml/more/coffee_script.rb

Instance Attribute Summary collapse

Attributes inherited from Compiler

#coffee_directory, #coffee_url

Instance Method Summary collapse

Methods inherited from Compiler

available_compilers, #compile_statement, #dependencies, #files, inherited, #javascript, new, #not_available!, #urls

Constructor Details

#initialize(runtime = nil) ⇒ JohnsonCompiler

Returns a new instance of JohnsonCompiler.



67
68
69
70
71
72
73
74
# File 'lib/haml/more/coffee_script.rb', line 67

def initialize(runtime = nil)
  super
  require "johnson"
  @runtime = runtime || Johnson::Runtime.new
  prepare_runtime
rescue Exception # LoadError
  not_available!
end

Instance Attribute Details

#runtimeObject

Returns the value of attribute runtime.



66
67
68
# File 'lib/haml/more/coffee_script.rb', line 66

def runtime
  @runtime
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


76
77
78
79
# File 'lib/haml/more/coffee_script.rb', line 76

def available?
  # CoffeeScript currently not working properly on Spidermonkey
  false
end

#prepare_runtimeObject



81
82
83
# File 'lib/haml/more/coffee_script.rb', line 81

def prepare_runtime
  runtime.load(*files)
end

#render(text) ⇒ Object



85
86
87
# File 'lib/haml/more/coffee_script.rb', line 85

def render(text)
  runtime.evaluate compile_statement(text)
end