package ppx_bsx

  1. Overview
  2. Docs
ReasonReact JSX for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

2.0.0.tar.gz
md5=33fdc21684128f6c3570d562d8335918
sha512=3a05e061835e3df1ffba8a728c73aa4bcb5d1e6cbe3f8bdd9357f6e8a0ba796c2bff3bc95cba4da4014325dabf3fdb97323049f22362dbeaf61356206bd3cd37

Description

ReasonReact JSX v3 for OCaml, ReasonReact 0.7+ and BuckleScript 6.0+ required

README

ppx_bsx

OCaml JSX for ReasonReact.

Install

ppx_bsx depends on ppx_lib, which means that ppx_bsx doesn't support bs-platform 5.x, so first step is configuring your project to "bs-platform": "^6.0.1".

Install ppx_bsx with opam or esy, and add ppx_bsx executable to bs-config.json:

{
  "ppx-flags": [
    "./_opam/bin/ppx_bsx",
    "./node_modules/bs-platform/lib/bsppx.exe -bs-jsx 3"
  ]
}

Replace ./_opam/bin/ppx_bsx to actual ppx_bsx installed path.

Basic Usage

This is how it feel:

[%bsx "
<Container>
  <h1>Nice example</h1>
  <nav className="(styles "sidebar")">
    This is sidebar
  </nav>
  <div className="(styles "content")">
    "{j|这是主内容|j}"
  </div>
</Container>
"]

Simple Rules

  • Break [%bsx ""] into

    [%bsx "
    
    "]
    

    and ignore the first and last quotation marks.

  • When you need OCaml expression, wrap it with double quotation marks, otherwise

  • For string literal value, just use single quotation marks

  • For single text node, you don't need to wrap it to ReasonReact.string, (surprisedly) <span>Hello, World</span> or <span>"{j|你好,世界|j}"</span> is accepted

  • {|你好|} will be transformed to {j|你好|j} automatically

Dependencies (4)

  1. dune >= "1.9"
  2. ppxlib < "0.9.0"
  3. markup
  4. ocaml = "4.06.1"

Dev Dependencies

None

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.