Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
jg_template.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
(* jg_template.ml Copyright (c) 2012 - by Masaki WATANABE License: see LICENSE *) open Jg_types (** Internally, interpretted result is outputed to `output:(string -> unit)` interface. *) type 'a internal_interp = ?env:Jg_types.environment -> ?models:(string * Jg_types.tvalue) list -> output:(tvalue -> unit) -> ?ctx:Jg_types.context -> 'a -> unit (** Externally, interpretted result is outputed as string. *) type 'a external_interp = ?env:Jg_types.environment -> ?ctx:Jg_types.context -> ?models:(string * Jg_types.tvalue) list -> 'a -> string let content (fn : 'a internal_interp) : 'a external_interp = fun ?(env=std_env) ?ctx ?(models=[]) (arg:'a) -> let buffer = Buffer.create 1024 in let output x = Buffer.add_string buffer (Jg_runtime.string_of_tvalue x) in let () = fn ~env ~models ~output ?ctx arg in Buffer.contents buffer let from_chan = content (Jg_interp.from_chan ?file_path:None) let from_file = content Jg_interp.from_file let from_string = content (Jg_interp.from_string ?file_path:None)