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
- #hamlcoffee_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
33 34 35 |
# File 'lib/haml_coffee_template/compiler.rb', line 33 def coffeescript_source File.read(CoffeeScript::Source.path) end |
#compile(source) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/haml_coffee_template/compiler.rb', line 21 def compile(source) runtime.call( "HamlCoffeeTemplate.compile", source, HamlCoffeeTemplate.configuration. ) end |
#hamlcoffee_source ⇒ Object
37 38 39 |
# File 'lib/haml_coffee_template/compiler.rb', line 37 def hamlcoffee_source File.read(HamlCoffeeTemplate.configuration.hamlcoffee_path) end |
#runtime_source ⇒ Object
29 30 31 |
# File 'lib/haml_coffee_template/compiler.rb', line 29 def runtime_source [coffeescript_source, hamlcoffee_source, wrapper_source].join(";") end |
#template(name, source) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/haml_coffee_template/compiler.rb', line 11 def template(name, source) runtime.call( "HamlCoffeeTemplate.template", source, name, HamlCoffeeTemplate.configuration.namespace, HamlCoffeeTemplate.configuration. ) end |
#wrapper_script_path ⇒ Object
45 46 47 |
# File 'lib/haml_coffee_template/compiler.rb', line 45 def wrapper_script_path File.("wrapper.js", __dir__) end |
#wrapper_source ⇒ Object
41 42 43 |
# File 'lib/haml_coffee_template/compiler.rb', line 41 def wrapper_source File.read(wrapper_script_path) end |