Sha256: b87acab29f2d1ae75a88a6431b1468ecb74e8711c6d405764bc5e92b6c26440a

Contents?: true

Size: 668 Bytes

Versions: 6

Compression:

Stored size: 668 Bytes

Contents

require 'execjs'
require 'react/jsx/template'
require 'react/jsx/jsx_transformer'
require 'react/jsx/babel_transformer'
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

    def self.transform(code)
      self.transformer ||= transformer_class.new(transform_options)
      self.transformer.transform(code)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
react-rails-1.4.1 lib/react/jsx.rb
react-rails-1.4.0 lib/react/jsx.rb
react-rails-1.3.3 lib/react/jsx.rb
react-rails-1.3.2 lib/react/jsx.rb
react-rails-1.3.1 lib/react/jsx.rb
react-rails-1.3.0 lib/react/jsx.rb