package embedded_ocaml_templates

  1. Overview
  2. Docs
EML is a simple templating language that lets you generate text with plain OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

embedded_ocaml_templates-0.8.tbz
sha256=c2ff640ab8123e5403f2b6ee480a07603ed2f1a8a97432f40d9ddec38d315321
sha512=9159e0f62f0aa1d7fb566c1b057f73ce5aba7c749af3af03ecf9c23591256d19dd664deb11c067a2514cafa2fe483125d95a65c2b2342a84d78447c6205a72c3

doc/src/embedded_ocaml_templates.EML_runtime/EML_runtime.ml.html

Source file EML_runtime.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(** [EML_runtime] provides runtime utilities for the code generated by the EML
    compiler. *)

(** [escape s] is the HTML-escaped version of the string [s].
    Characters '&', '<', '>', '"' and ''' are replaced by their HTMl encoding. *)
let escape s =
  let buffer = Buffer.create (String.length s) in
  String.iter
    (function
      | '&' ->
          Buffer.add_string buffer "&amp;"
      | '<' ->
          Buffer.add_string buffer "&lt;"
      | '>' ->
          Buffer.add_string buffer "&gt;"
      | '"' ->
          Buffer.add_string buffer "&quot;"
      | '\'' ->
          Buffer.add_string buffer "&#x27;"
      | c ->
          Buffer.add_char buffer c )
    s ;
  Buffer.contents buffer
OCaml

Innovation. Community. Security.