package html_of_jsx

  1. Overview
  2. Docs
On This Page
  1. Enable
  2. Aliases
Render HTML with JSX

Install

dune-project
 Dependency

Authors

Maintainers

Sources

html_of_jsx-0.1.1.tbz
sha256=2de32525b5f38b4765c1bbfeba35fcfcc6d26b66a244374e86e109129bb729a6
sha512=a5a27d16aed5c3f8fcacd72578ad63c63cd33276356883fcf282709a56b574a92d35d1af2ae18a61491a28a86b89f4571d8596e000ae4e06201758eb3d8892e5

doc/React-compatibility.html

React compatibility mode

The React compatibility mode eases migration from reason-react to html_of_jsx. It adds camelCase aliases for HTML attributes that React uses instead of the standard HTML names.

Enable

Turn on -react in your ppx configuration.

(libraries html_of_jsx)
(preprocess (pps html_of_jsx.ppx -react))

Aliases

The -react flag adds the following aliases. The standard HTML attribute names still work.

React name

HTML output

Type

className

class

string

htmlFor

for

string

tabIndex

tabindex

int

maxLength

maxlength

int

readOnly

readonly

bool

colSpan

colspan

int

rowSpan

rowspan

int

autoComplete

autocomplete

string

defaultValue

value

string

defaultChecked

checked

bool

JSX.render(
  <div className="card">
    <label htmlFor="email"> {JSX.string("Email")} </label>
    <input
      id="email"
      type_=`email
      tabIndex=1
      maxLength=100
      autoComplete="email"
      readOnly=true
    />
    <table>
      <tr> <td colSpan=2> {JSX.string("Full width")} </td> </tr>
    </table>
  </div>
)
JSX.render (
  <div className="card">
    <label htmlFor="email"> (JSX.string "Email") </label>
    <input
      id="email"
      type_=`email
      tabIndex=1
      maxLength=100
      autoComplete="email"
      readOnly=true
    />
    <table>
      <tr> <td colSpan=2> (JSX.string "Full width") </td> </tr>
    </table>
  </div>
)