-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91b470d
commit 6a1a2f0
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# `w-mlx` | ||
|
||
<br> | ||
|
||
[mlx](https://github.com/ocaml-mlx/mlx), an OCaml syntax dialect which adds JSX | ||
expressions, can be used with Dream for generating HTML. | ||
|
||
```ocaml | ||
let greet ~who () = | ||
<html> | ||
<head> | ||
<title>"Greeting"</title> | ||
</head> | ||
<body> | ||
<h1>"Good morning, " (JSX.string who) "!"</h1> | ||
</body> | ||
</html> | ||
let () = | ||
Dream.run | ||
@@ Dream.logger | ||
@@ Dream.router [ | ||
Dream.get "/" (fun _ -> | ||
let html = JSX.render <greet who="world" /> in | ||
Dream.html html) | ||
] | ||
``` | ||
|
||
<pre><code><b>$ cd example/w-mlx</b> | ||
<b>$ opam install --deps-only --yes .</b> | ||
<b>$ dune exec --root . ./mlx.exe</b></code></pre> | ||
|
||
<br> | ||
|
||
[Up to the example index](../#examples) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executable | ||
(name mlx) | ||
(libraries dream html_of_jsx) | ||
(preprocess (pps html_of_jsx.ppx))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(lang dune 3.16) | ||
|
||
(dialect | ||
(name mlx) | ||
(implementation | ||
(merlin_reader mlx) | ||
(extension mlx) | ||
(preprocess | ||
(run mlx-pp %{input-file})))) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
let greet ~who () = | ||
<html> | ||
<head> | ||
<title>"Greeting"</title> | ||
</head> | ||
<body> | ||
<h1>"Good morning, " (JSX.string who) "!"</h1> | ||
</body> | ||
</html> | ||
|
||
let () = | ||
Dream.run | ||
@@ Dream.logger | ||
@@ Dream.router [ | ||
Dream.get "/" (fun _ -> | ||
let html = JSX.render <greet who="world" /> in | ||
Dream.html html) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
opam-version: "2.0" | ||
|
||
depends: [ | ||
"ocaml" {>= "4.08.0"} | ||
"dream" | ||
"dune" {>= "3.16.0"} | ||
"mlx" | ||
"html_of_jsx" | ||
] |