add html.to_string_l

This commit is contained in:
Simon Cruanes 2022-03-29 16:42:02 -04:00
parent 091f2f7ff2
commit 5f59174087
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -19,6 +19,15 @@ let to_string ?(top=false) (self:elt) : string =
self out;
Out.to_string out
(** Convert a list of HTML elements to a string.
This is designed for fragments of HTML that are to be injected inside
a bigger context, as it's invalid to have multiple elements at the toplevel
of a HTML document. *)
let to_string_l (l:elt list) =
let out = Out.create () in
List.iter (fun f -> f out; Out.add_format_nl out) l;
Out.to_string out
let to_string_top = to_string ~top:true
(** Convert a HTML element to a stream. This might just convert