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.0.tbz
sha256=a62b73fe66b6e40196cc06cc0771184d42923e9c571183ecc793cd58f0b407dd
sha512=b25ba1321a5413942bf781aa9a8cacdc92eb03c1099a4c564a061b32cc57bbae571465d123d98548aba1cc78c3bb79fbf415e29934a8318c15ab9ffc0ea8cceb

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