Module: React::JSX
- Defined in:
- lib/react/jsx.rb
Class Method Summary collapse
Class Method Details
.compile(code) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/react/jsx.rb', line 29 def self.compile(code) if rubyracer? context.transform(code)['code'] elsif rubyrhino? context['transform'].new(code)['code'] else context.call('JSXTransformer.transform', code)['code'] end end |
.context ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/react/jsx.rb', line 6 def self.context unless @context content = File.read(React::Source.bundled_path_for('JSXTransformer.js')) @context = if rubyracer? V8::Context.new.eval("module={}; exports={}; #{content}; module.exports") elsif rubyrhino? Rhino::Context.new.eval("module={}; exports={}; #{content}; module.exports") else ExecJS.compile(content) end end @context end |
.rubyracer? ⇒ Boolean
21 22 23 |
# File 'lib/react/jsx.rb', line 21 def self.rubyracer? ExecJS.runtime == ExecJS::Runtimes::RubyRacer end |
.rubyrhino? ⇒ Boolean
25 26 27 |
# File 'lib/react/jsx.rb', line 25 def self.rubyrhino? ExecJS.runtime == ExecJS::Runtimes::RubyRhino end |