Class: Rt::Transformer
- Inherits:
-
Object
- Object
- Rt::Transformer
- Includes:
- Singleton
- Defined in:
- lib/rt/transformer.rb
Instance Method Summary collapse
- #call(code, options = {}) ⇒ Object
-
#initialize ⇒ Transformer
constructor
A new instance of Transformer.
Constructor Details
#initialize ⇒ Transformer
Returns a new instance of Transformer.
8 9 10 11 12 |
# File 'lib/rt/transformer.rb', line 8 def initialize js_path = File.join File.dirname(__FILE__), "../js/react-templates.min.js" contents = "var global = global || this;" + File.read(js_path) @context = ExecJS.compile(contents) end |
Instance Method Details
#call(code, options = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/rt/transformer.rb', line 14 def call code, ={} name = [:name] || nil modules = [:modules] || "commonjs" @context.call "global.reactTemplates.convertTemplateToReact", code, {modules: modules, name: name} end |