Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
MustacheSourceA module for creating and rendering mustache templates in OCaml.
and desc = | String of string| Escaped of dotted_name| Unescaped of dotted_name| Section of section| Inverted_section of section| Partial of partial| Param of param| Concat of t list| Comment of stringRead template files; those function may raise Parse_error.
pp_template_parse_error fmt err prints a human-readable description of a template parse error on the given formatter. The function does not flush the formatter (in case you want to use it within boxes), so you should remember to do it yourself.
| try ignore (Mustache.of_string "{{!") with Mustache.Parse_error err ->
Format.eprintf "%a@." Mustache.pp_template_parse_error err |
pp fmt template print a template as raw mustache to the formatter fmt.
Alias for compatibility
to_string template uses to_formatter in order to return a string representing the template as raw mustache.
type render_error_kind = | Invalid_param of {name : dotted_name;expected_form : string;}| Missing_variable of {name : dotted_name;}| Missing_section of {name : dotted_name;}| Missing_partial of {name : name;}Render templates; those functions may raise Render_error.
val render_fmt :
?strict:bool ->
?partials:(name -> t option) ->
Format.formatter ->
t ->
Json.t ->
unitrender_fmt fmt template json renders template, filling it with data from json, printing it to formatter fmt.
For each partial p, if partials p is Some t then the partial is substituted by t. Otherwise, the partial is substituted by the empty string is strict is false. If strict is true, a Missing_partial error is raised.
val render_buf :
?strict:bool ->
?partials:(name -> t option) ->
Buffer.t ->
t ->
Json.t ->
unitrender_buf buf template json renders template, filling it with data from json, printing it to the buffer buf. See render_fmt.
render template json renders template, filling it with data from json, and returns the resulting string. See render_fmt.
val fold :
string:(string -> 'a) ->
section:(inverted:bool -> dotted_name -> 'a -> 'a) ->
escaped:(dotted_name -> 'a) ->
unescaped:(dotted_name -> 'a) ->
partial:
(?indent:int ->
name ->
?params:(int * name * 'a) list ->
t option Lazy.t ->
'a) ->
param:(?indent:int -> name -> 'a -> 'a) ->
comment:(string -> 'a) ->
concat:('a list -> 'a) ->
t ->
'afold template is the composition of f over parts of template, called in order of occurrence, where each f is one of the labelled arguments applied to the corresponding part. The default for f is the identity function.
expand_partials f template is template where for each Partial p node, p.contents now evaluates to f p.name if they were evaluating to None. Note that no lazy is forced at this point, and calls to f are delayed until p.contents is forced.
Escape &, "\"", ', < and > character for html rendering.
{{name}}
{{{name}}}
{{^person}} {{/person}}
{{#person}} {{/person}}
{{> box}} or
{{< box}}
{{$param1}} default value for param1 {{/param1}}
{{$param2}} default value for param1 {{/param2}}
{{/box}}Variant of the t mustache datatype which includes source-file locations, and associated functions.
Erase locations from a mustache value of type With_locations.t.
Add the dummy_loc location to each node of a mustache value of type t.