aantron/dream

Explicitly setting Reason mode in the eml templater

Closed this issue · 0 comments

Currently, the way the templater decides whether it should emit Reason syntax after preprocessing the template, is by checking whether the extension is .re, so, e.g., foo.eml.re:

dream/src/eml/eml.ml

Lines 787 to 791 in b8a46f4

let reason, extension =
match Filename.extension input_file with
| ".re" -> true, ".re"
| _ -> false, ".ml"
in

Given that we recommend using .eml.html files as a project scales, we need a command-line argument to the templater to explicitly tell it to emit Reason code.

The command-line argument would be added around here:

dream/src/eml/main.ml

Lines 24 to 28 in b8a46f4

let options = Arg.align [
"--workspace",
Arg.Set_string workspace_path,
"PATH Relative path to the Dune workspace for better locations";
]

which uses stdlib module Arg.

The command line would be passed to the dream_eml binary from dune rules:

(rule
(targets template.re)
(deps template.eml.re)
(action (run dream_eml %{deps} --workspace %{workspace_root})))