pjlast / ppx_dream_eml

Straightforward ppx to write Dream .eml templates directly in your .ml files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ppx_dream_eml

A very straightforward extension that allows you to write Dream's .eml templates directly in your OCaml code without the need to add directives to dune.

This also has the benefit of playing nice with your syntax highlighting and code editor, since the code produced will be valid OCaml.

The processing code is lifted directly from the Dream repository.

Usage

Install the library:

opam install ppx_dream_eml

Add the ppx to your dune file:

...
  (preprocess (pps ... ppx_dream_eml))
...

And then use the eml extension in your OCaml code and write .eml templates as you normally would, except put the template part inside the extension:

let render message = {%eml|
<html>
<body>
  <p>The message is <b><%s message %></b>!</p>
</body>
</html>
|}

Known issues

Errors won't quite map to the right places in your eml. Could perhaps be fixed with a more complicated implementation.

About

Straightforward ppx to write Dream .eml templates directly in your .ml files.

License:MIT License


Languages

Language:OCaml 100.0%