JSX for Mercury
JavaScript
Pull request Compare This branch is 3 commits ahead, 28 commits behind insin:master.
Latest commit 4b5d626 May 27, 2014 @Raynos test for class
Permalink
Failed to load latest commit information.
bin
test
vendor/fbtransform
.gitignore
.npmignore
.travis.yml
HISTORY.md
LICENSE
README.md
gulpfile.js Remove stuff we don're really need from the gulp build Mar 21, 2014
main.js
package.json

README.md

mercury-jsx

React's JSX Transformer, tweaked to output calls to Mercury's h() function in the format it expects, with the tag name in a String and any children present wrapped in an Array.

The current version of mercury-jsx is based on version 0.10.0 of React's JSX Transformer.

Put the following jsx pragma at the beginning of files you want to process:

/** @jsx h */

Only output has been tweaked, but there's no special treatment for custom tag names - the transformer will output a warning if it sees an unknown tag name and output an h() call anyway.

Other than that, the rest of React's JSX documentation should still apply:

Command Line Usage

npm install -g mercury-jsx
mercury-jsx --watch src/ build/

Run mercury-jsx --help for more information.

Module Usage

npm install mercury-jsx
var msx = require('mercury-jsx')

Module API

msx.transform(source)

Transforms XML-like syntax in the given source into native JavaScript function calls using Mercury's h() function, returning the transformed source.

Examples

Example inputs and outputs are in test/jsx and test/js, respectively.

An example gulpfile.js is provided, which implements an msxTransform() function using msx.transform().


Apache 2.0 Licensed, as per React