package server-reason-react
Rendering React components on the server natively
Install
Dune Dependency
Authors
Maintainers
Sources
server-reason-react-0.3.1.tbz
sha256=b97fbe6a7c3e5e1a7775e0f6498f257acaaa7e272177a9a3e0e50b7a49408d7c
sha512=b27a94618c367c80efef83a41c2a59c9cc7848fd753049ed40fa1f2cface1ef34cf3a995835bf08e2eb59c3186911f429b4706ed07dcb9724df6af5eb012a31d
doc/src/server-reason-react.html/Html.ml.html
Source file Html.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
(* Based on https://github.com/facebook/react/blob/97d75c9c8bcddb0daed1ed062101c7f5e9b825f4/packages/react-dom-bindings/src/server/escapeTextForBrowser.js#L51-L98 *) (* https://discuss.ocaml.org/t/html-encoding-of-string/4289/4 *) let encode s = let buffer = Buffer.create (String.length s * 2) in s |> String.iter (function | '&' -> Buffer.add_string buffer "&" | '<' -> Buffer.add_string buffer "<" | '>' -> Buffer.add_string buffer ">" | '"' -> Buffer.add_string buffer """ | '\'' -> Buffer.add_string buffer "'" | c -> Buffer.add_char buffer c); Buffer.contents buffer let is_self_closing_tag = function (* Take the list from https://github.com/facebook/react/blob/97d75c9c8bcddb0daed1ed062101c7f5e9b825f4/packages/react-dom-bindings/src/shared/omittedCloseTags.js but found https://github.com/wooorm/html-void-elements to be more complete. *) | "area" | "base" | "basefont" | "bgsound" | "br" | "col" | "command" | "embed" | "frame" | "hr" | "image" | "img" | "input" | "keygen" | "link" (* | "menuitem" *) | "meta" | "param" | "source" | "track" | "wbr" -> true | _ -> false
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>