├── .gitignore ├── .ocamlformat ├── LICENSE ├── README.md ├── bsconfig.json ├── package.json ├── src └── ppx_tea_jsx.ml └── test ├── test.ml └── test.re /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.log 3 | /node_modules 4 | *.cmi 5 | *.cmj 6 | *.cmt 7 | /lib 8 | *.js 9 | .merlin 10 | -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = sparse 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Ozan Sener 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ppx-tea-jsx    [![Version 0.6.0][npm-img]][npm] 2 | 3 | [npm-img]: https://img.shields.io/npm/v/ppx-tea-jsx.svg 4 | [npm]: https://www.npmjs.com/package/ppx-tea-jsx 5 | 6 | [Reason](https://reasonml.github.io) JSX syntax support for 7 | [BuckleScript-TEA](https://github.com/OvermindDL1/bucklescript-tea) library. 8 | 9 | ## Installation 10 | 11 | 1. Install via npm or Yarn: 12 | 13 | ```sh 14 | yarn add --dev ppx-tea-jsx 15 | ``` 16 | 17 | 2. Add the PPX to your `bsconfig.json`: 18 | 19 | ```json 20 | { 21 | "ppx-flags": ["ppx-tea-jsx/ppx"] 22 | } 23 | ``` 24 | 25 | ## Usage 26 | 27 | You can pass JSX expressions to any function that expects `Vdom.t`. 28 | 29 | ### HTML elements 30 | 31 | ```reason 32 | let view = _model => 33 |
34 |
; 36 | ``` 37 | 38 | ```reason 39 | 43 | ``` 44 | 45 | #### Literals 46 | 47 | ```reason 48 | "Addition: " 5 '+' 25.5 49 | ``` 50 | 51 | #### Punning 52 | 53 | ```reason 54 | let id = "fifty"; 55 | let className = None; 56 | 57 | let _ =
; 58 | ``` 59 | 60 | #### Children spread 61 | 62 | ```reason 63 | let buttons_list_fn = () => [
; 118 | 119 | let _view = model => { 120 | let onChangeOpt = value => 121 | try (value->int_of_string->Set->Some) { 122 | | _ => None 123 | }; 124 | ; 125 | }; 126 | --------------------------------------------------------------------------------