Sha256: 73265310f89042ce36bff99f9130dfd719d7f30fa42f4c0adcea8aae42f8c0af

Contents?: true

Size: 610 Bytes

Versions: 10

Compression:

Stored size: 610 Bytes

Contents

require 'execjs'
require 'react/source'
require 'react/jsx/template'

module React
  module JSX
    def self.context
      # TODO: create React::Source::contents_for
      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

    def self.transform(code)
      result = context.call('JSXTransformer.transform', code)
      return result['code']
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
react-rails-0.13.0.0 lib/react/jsx.rb
react-rails-0.12.2.0 lib/react/jsx.rb
react-rails-0.12.1.0 lib/react/jsx.rb
react-rails-0.12.0.0 lib/react/jsx.rb
react-rails-0.11.1.0 lib/react/jsx.rb
react-rails-0.10.0.0 lib/react/jsx.rb
react-rails-0.9.0.0 lib/react/jsx.rb
react-rails-0.8.0.0 lib/react/jsx.rb
react-rails-0.5.2.0 lib/react/jsx.rb
react-rails-0.5.1.0 lib/react/jsx.rb