Conghao97's picture tcftrees's picture
ProgramGen release
d086025
|
Raw History Blame Contribute Delete
1.24 kB

htr CLI usage

The CLI usage of the HTML to React transform.

Install

cargo install htr_cli

Usage

Transform props to React (attributes and inline styles are converted, the HTML structure is preserved):

htr transform --html '<div class="something" for="mystuff" tabindex="2" style="color: white; background-color: black">'

Output:

<div className="something" htmlFor="mystuff" tabIndex="2" style={{color: "white", backgroundColor: "black"}}>

Transform to a full React component (pass a component name):

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).