package mustache

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
exception Invalid_param of string

A module for creating and rendering mustache templates in OCaml.

exception Invalid_template of string
exception Missing_variable of string

Raised when a missing variable in a template is not substituted

module Json : sig ... end
type t
val parse_lx : Lexing.lexbuf -> t

Read

val of_string : string -> t
val to_formatter : Format.formatter -> t -> unit

to_formatter fmt template print a template as raw mustache to the formatter fmt.

val to_string : t -> string

to_string template uses to_formatter in order to return a string representing the template as raw mustache.

val render_fmt : Format.formatter -> t -> Json.t -> unit

render_fmt fmt template json render template, filling it with data from json, printing it to formatter fmt.

val render : t -> Json.t -> string

render template json use render_fmt to render template with data from json and returns the resulting string.

module Infix : sig ... end

Shortcut for concatening two templates pieces.

val escape_html : string -> string

Escape &, "\"", ', < and > character for html rendering.

val iter_var : t

{{.}}

val raw : string -> t

<p>This is raw text.</p>

val escaped : string -> t

{{name}}

val unescaped : string -> t

{{{name}}}

val inverted_section : string -> t -> t

{{^person}} {{/person}}

val section : string -> t -> t

{{#person}} {{/person}}

val partial : string -> t

{{> box}}

val comment : string -> t

{{! this is a comment}}

val concat : t list -> t

Group a t list as a single t.

OCaml

Innovation. Community. Security.