Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/mustache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ let parse_lx (lexbuf: Lexing.lexbuf) : Locs.t =
Mustache_lexer.(handle_standalone mustache lexbuf)

let of_string s = parse_lx (Lexing.from_string s)
let of_channel c = parse_lx (Lexing.from_channel c)
let of_file f =
let c = open_in f in
let ret = of_channel c in
close_in c;
ret

(* Utility module, that helps looking up values in the json data during the
rendering phase. *)
Expand Down Expand Up @@ -209,6 +215,8 @@ module Without_locations = struct

let parse_lx lexbuf = erase_locs (parse_lx lexbuf)
let of_string s = erase_locs (of_string s)
let of_channel c = erase_locs (of_channel c)
let of_file f = erase_locs (of_file f)

let pp = pp
let to_formatter = pp
Expand Down
2 changes: 2 additions & 0 deletions lib/mustache.mli
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ and partial =
(** Read *)
val parse_lx : Lexing.lexbuf -> t
val of_string : string -> t
val of_channel : in_channel -> t
val of_file : string -> t

(** [pp fmt template] print a template as raw mustache to
the formatter [fmt]. *)
Expand Down