├── .gitignore ├── .npmignore ├── LICENSE.md ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | node_modules/ 3 | 4 | .DS_Store 5 | *.db 6 | *.bak 7 | *.tmp 8 | *.cmd 9 | ~* 10 | 11 | upload.py -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.settings 3 | /.project 4 | /.gitignore 5 | /node_modules 6 | /test 7 | /.tmp 8 | 9 | .DS_Store 10 | 11 | *.db 12 | *.bak 13 | *.tmp 14 | *.cmd 15 | ~* 16 | 17 | upload.py -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 baidu.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fis-parser-react 2 | 3 | A parser plugin for [fis](https://github.com/fis-dev/fis) to precompile [react](http://facebook.github.io/react/). 4 | 5 | ##Usage 6 | 7 | * install this plugin (make sure you have installed [fis](https://github.com/fis-dev/fis) before). 8 | 9 | ```shell 10 | npm install -g fis-parser-react 11 | ``` 12 | 13 | * create a project 14 | 15 | project 16 | - foo.jsx 17 | - fis-conf.js 18 | 19 | * vi ``fis-conf.js`` 20 | 21 | ```javascript 22 | fis.config.set('project.fileType.text', 'jsx'); //*.jsx files are text file. 23 | fis.config.set('modules.parser.jsx', 'react'); //compile *.jsx with fis-parser-react plugin 24 | fis.config.set('roadmap.ext.jsx', 'js'); //*.jsx are exactly treat as *.js 25 | ``` 26 | * write a jsx file 27 | 28 | ```javascript 29 | /** @jsx React.DOM */ 30 | var HelloMessage = React.createClass({ 31 | render: function() { 32 | return
Hello {this.props.name}
; 33 | } 34 | }); 35 | 36 | React.renderComponent( 37 | , 38 | document.getElementById('container') 39 | ); 40 | ``` 41 | 42 | * release your project 43 | 44 | ```shell 45 | cd project # get into project 46 | fis release -d output # release your project to output dir 47 | ``` 48 | 49 | * you will get a compiled js file at ``output/index.js`` 50 | 51 | ```javascript 52 | /** @jsx React.DOM */ 53 | var HelloMessage = React.createClass({displayName: 'HelloMessage', 54 | render: function() { 55 | return React.DOM.div(null, "Hello ", this.props.name); 56 | } 57 | }); 58 | 59 | React.renderComponent( 60 | HelloMessage( {name:"John"} ), 61 | document.getElementById('container') 62 | ); 63 | ``` 64 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var react = require('react-tools'); 4 | 5 | module.exports = function(content){ 6 | return react.transform(content); 7 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fis-parser-react", 3 | "version": "0.0.2", 4 | "description": "a parser plugin for fis to precompile react", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/fouber/fis-parser-react.git" 12 | }, 13 | "keywords": [ 14 | "fis", 15 | "react", 16 | "plugin", 17 | "parser" 18 | ], 19 | "author": "fouber ", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/fouber/fis-parser-react/issues" 23 | }, 24 | "homepage": "https://github.com/fouber/fis-parser-react", 25 | "dependencies" : { 26 | "react-tools" : "~0.12.2" 27 | } 28 | } 29 | --------------------------------------------------------------------------------