Sha256: 0c901671fc7652e1a42dca987951946c83c141fae1ec48544a1ea2290a77f8b0

Contents?: true

Size: 862 Bytes

Versions: 25

Compression:

Stored size: 862 Bytes

Contents

require 'execjs'
require 'react/jsx/processor'
require 'react/jsx/template'
require 'react/jsx/jsx_transformer'
require 'react/jsx/babel_transformer'
require 'react/jsx/sprockets_strategy'
require 'rails'

module React
  module JSX
    DEFAULT_TRANSFORMER = BabelTransformer
    mattr_accessor :transform_options, :transformer_class, :transformer

    # You can assign `config.react.jsx_transformer_class = `
    # to provide your own transformer. It must implement:
    # - #initialize(options)
    # - #transform(code) => new code
    self.transformer_class = DEFAULT_TRANSFORMER

    # @param code [String] JSX code to transform into JavaScript
    # @return [String] plain, browser-ready JavaScript code
    def self.transform(code)
      self.transformer ||= transformer_class.new(transform_options)
      self.transformer.transform(code)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
react-rails-2.7.1 lib/react/jsx.rb
react-rails-2.7.0 lib/react/jsx.rb
react-rails-2.7.0.rc.2 lib/react/jsx.rb
react-rails-2.7.0.rc.1 lib/react/jsx.rb
react-rails-2.7.0.rc.0 lib/react/jsx.rb
react-rails-2.6.2 lib/react/jsx.rb
react-rails-2.6.1 lib/react/jsx.rb
react-rails-2.6.0 lib/react/jsx.rb
react-rails-2.5.0 lib/react/jsx.rb
react-rails-2.4.7 lib/react/jsx.rb
react-rails-2.4.6 lib/react/jsx.rb
react-rails-2.4.5 lib/react/jsx.rb
react-rails-2.4.4 lib/react/jsx.rb
react-rails-2.4.4.pre lib/react/jsx.rb
react-rails-2.4.3 lib/react/jsx.rb
react-rails-2.4.2 lib/react/jsx.rb
react-rails-2.4.1 lib/react/jsx.rb
react-rails-2.4.0 lib/react/jsx.rb
react-rails-2.3.1 lib/react/jsx.rb
react-rails-2.3.0 lib/react/jsx.rb