File size: 1,241 Bytes
d086025 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # htr CLI usage
The CLI usage of the HTML to React transform.
## Install
```sh
cargo install htr_cli
```
## Usage
Transform props to React (attributes and inline styles are converted, the HTML
structure is preserved):
```sh
htr transform --html '<div class="something" for="mystuff" tabindex="2" style="color: white; background-color: black">'
```
Output:
```html
<div className="something" htmlFor="mystuff" tabIndex="2" style={{color: "white", backgroundColor: "black"}}>
```
Transform to a full React component (pass a component name):
```sh
htr transform --html '<div class="something" for="mystuff" tabindex="2" style="color: white; background-color: black">' --component-name 'Main'
```
## Flags
| Flag | Description |
| ----------------- | -------------------------------------------------------- |
| `--html` | Raw HTML input to transform (required). |
| `--component-name`| Component name; when provided, output is a full React component instead of transformed props/markup only. |
## Subcommands
- `transform` — transform HTML input to React JSX (props-only by default, or a
full component when `--component-name` is supplied).
|