package mustache-cli

  1. Overview
  2. Docs
CLI for Mustache logic-less templates

Install

Dune Dependency

Authors

Maintainers

Sources

mustache-3.3.0.tbz
sha256=370b7eae6315f24d457d85c393aafe4a448a2b9c41d00ac0fa0dd1ac7728adfc
sha512=64795b0a0a2644961619cfdf43d9b5904181eb783ac1e5dc2a44c7bfb9ebf6fe9fb03bc1f31aa53a760b3ca6676b93d494e17b3f89f07c3cb3e4a85927cfbca2

README.md.html

ocaml-mustache

mustache.js logic-less templates in OCaml

Example usage

let tmpl =
  try
    Mustache.of_string "Hello {{name}}\n\
                        Mustache is:\n\
                        {{#qualities}}\
                        * {{name}}\n\
                        {{/qualities}}"
  with Mustache.Parse_error err ->
    Format.eprintf "%a@."
      Mustache.pp_template_parse_error err;
    exit 3

let json =
  `O [ "name", `String "OCaml"
     ; "qualities", `A [ `O ["name", `String "awesome"]
                       ; `O ["name", `String "simple"]
                       ; `O ["name", `String "fun"]
                       ]
     ]

let rendered =
  try Mustache.render tmpl json
  with Mustache.Render_error err ->
    Format.eprintf "%a@."
      Mustache.pp_render_error err;
    exit 2

Supported template language

ocaml-mustache accepts the whole Mustache template language, except:

  • it does not support setting delimiter tags to something else than '{{' and '}}'.

  • it does not support lambdas inside the provided data

It is automatically tested against the latest mustache specification testsuite.

ocaml-mustache also supports template inheritance / partials with parameters, tested against the semi-official specification.

Todo/Wish List

  • Support for ropes

http://mustache.github.io/

OCaml

Innovation. Community. Security.