Sha256: 948775f944e20c7ae2722793f45a1250ff86468c4444d763eab9bd13a9c4c12e

Contents?: true

Size: 587 Bytes

Versions: 1

Compression:

Stored size: 587 Bytes

Contents

require 'execjs'
require 'react/source'

module Middleman
  module React
    module JSX
      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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-react-0.0.2 lib/middleman-react/jsx.rb