Sha256: fcfdaafaf61860cb241c9ebd4615b8b0101a6493493dac3bcc7520d387382815

Contents?: true

Size: 662 Bytes

Versions: 2

Compression:

Stored size: 662 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 `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

2 entries across 2 versions & 1 rubygems

Version Path
react-rails-1.2.0 lib/react/jsx.rb
react-rails-1.1.0 lib/react/jsx.rb