Module: Middleman::React::JSX
- Defined in:
- lib/middleman-react/jsx.rb
Overview
Methods for invoking the JSXTransformer via ExecJS
Class Method Summary collapse
Class Method Details
.context ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/middleman-react/jsx.rb', line 10 def self.context contents = # If execjs uses therubyracer, there is no 'global'. Make sure # we have it so JSX script can work properly. 'var global = global || this;' + File.read(::React::Source.bundled_path_for('JSXTransformer.js')) @context ||= ExecJS.compile(contents) end |
.transform(code) ⇒ Object
19 20 21 |
# File 'lib/middleman-react/jsx.rb', line 19 def transform(code) context.call('JSXTransformer.transform', code)['code'] end |