Project

jsx

0.01
No commit activity in last 3 years
No release in over 3 years
Transform JSX to JavaScript from Ruby. Includes a Tilt template for use with Sinatra (or any Tilt project).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
>= 0
 Project Readme

JSX Build Status Gem Version

A Ruby interface to Facebook's JSX transformer, broken out of react-rails. You can:

  • convert JSX willy-nilly
  • Use JSX::Template with a Tilt environment (for example, Sinatra)

Installation

gem "jsx"
bundle install

Ad Hoc Transform

You can access the transformer directly. Pass it some JavaScript with JSX. Optionally, pass strip_types or harmony. For example:

compiled = JSX.transform("<h1>Hello {name}</h1>", strip_types: true, harmony: true)
# 'React.createElement("h1", {className: "greeting"}, "Hello ", name)'

With Tilt

Tilt can automatically convert .jsx files. After loading Tilt and JSX, require jsx/tilt. For example:

require 'tilt'
require 'jsx'
require 'jsx/tilt'

To use harmony or strip_types in this case, assign them to JSX::Template.transform_options. For example:

JSX::Template.transform_options = {strip_types: true}

Now, the template will strip types from JSX code.

License

  • Facebook's JSX Transformer (part of React): BSD
  • This Ruby code: MIT