Class: HamlCoffeeTemplate::Compiler
- Inherits:
-
Object
- Object
- HamlCoffeeTemplate::Compiler
- Defined in:
- lib/haml_coffee_template/compiler.rb
Instance Attribute Summary collapse
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
Instance Method Summary collapse
- #coffeescript_source ⇒ Object
- #compile(source) ⇒ Object
- #haml_coffee_source ⇒ Object
-
#initialize ⇒ Compiler
constructor
A new instance of Compiler.
- #runtime_source ⇒ Object
- #template(name, source) ⇒ Object
- #wrapper_script_path ⇒ Object
- #wrapper_source ⇒ Object
Constructor Details
#initialize ⇒ Compiler
Returns a new instance of Compiler.
7 8 9 |
# File 'lib/haml_coffee_template/compiler.rb', line 7 def initialize @runtime = ExecJS.compile(runtime_source) end |
Instance Attribute Details
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
5 6 7 |
# File 'lib/haml_coffee_template/compiler.rb', line 5 def runtime @runtime end |
Instance Method Details
#coffeescript_source ⇒ Object
36 37 38 |
# File 'lib/haml_coffee_template/compiler.rb', line 36 def coffeescript_source File.read(CoffeeScript::Source.path) end |
#compile(source) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/haml_coffee_template/compiler.rb', line 23 def compile(source) runtime.call( "HamlCoffeeTemplate.compile", source, HamlCoffeeTemplate.configuration., HamlCoffeeTemplate.configuration. ) end |
#haml_coffee_source ⇒ Object
40 41 42 |
# File 'lib/haml_coffee_template/compiler.rb', line 40 def haml_coffee_source File.read(HamlCoffeeTemplate.configuration.haml_coffee_path) end |
#runtime_source ⇒ Object
32 33 34 |
# File 'lib/haml_coffee_template/compiler.rb', line 32 def runtime_source [coffeescript_source, haml_coffee_source, wrapper_source].join(";") end |
#template(name, source) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/haml_coffee_template/compiler.rb', line 11 def template(name, source) = HamlCoffeeTemplate.configuration..dup [:name] = name [:namespace] = HamlCoffeeTemplate.configuration.namespace runtime.call( "HamlCoffeeTemplate.template", source, , HamlCoffeeTemplate.configuration., ) end |
#wrapper_script_path ⇒ Object
48 49 50 |
# File 'lib/haml_coffee_template/compiler.rb', line 48 def wrapper_script_path File.("wrapper.js", __dir__) end |
#wrapper_source ⇒ Object
44 45 46 |
# File 'lib/haml_coffee_template/compiler.rb', line 44 def wrapper_source File.read(wrapper_script_path) end |