package mustache

All checked builds pass
  1. Overview
  2. Docs
Mustache logic-less templates in OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

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

Description

Read and write mustache templates, and render them.

Added to opam-repository:

README

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/

Dependencies (3)

  1. ocaml >= "4.08"
  2. menhir >= "20180703"
  3. dune >= "2.7"

Dev Dependencies (1)

  1. odoc with-doc

Optional Dependencies

None

Conflicts

None

Build status

Results of building mustache with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
3.3.0 (this version) good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure