Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rgrinberg/ocaml-mustache
mustache.js logic-less templates in OCaml
https://github.com/rgrinberg/ocaml-mustache
mustache mustache-templates ocaml
Last synced: 3 months ago
JSON representation
mustache.js logic-less templates in OCaml
- Host: GitHub
- URL: https://github.com/rgrinberg/ocaml-mustache
- Owner: rgrinberg
- License: mit
- Created: 2014-01-23T04:30:16.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-05-31T12:47:36.000Z (7 months ago)
- Last Synced: 2024-09-29T18:05:09.066Z (3 months ago)
- Topics: mustache, mustache-templates, ocaml
- Language: OCaml
- Size: 344 KB
- Stars: 82
- Watchers: 11
- Forks: 25
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.md
Awesome Lists containing this project
README
ocaml-mustache
==============mustache.js logic-less templates in OCaml
Example usage
-------------```ocaml
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 3let 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 dataIt is automatically tested against the latest
[mustache specification testsuite](https://github.com/mustache/spec/tree/v1.1.3).ocaml-mustache also supports template inheritance / partials with parameters,
tested against the [semi-official specification](https://github.com/mustache/spec/pull/75).Todo/Wish List
-----------
* Support for ropeshttp://mustache.github.io/