package server-reason-react
Rendering React components on the server natively
Install
Dune Dependency
Authors
Maintainers
Sources
server-reason-react-0.2.0.tbz
sha256=f7e93b2c24e6420ed7352f5b04ff028ea6ea8b9b91679bbce43aadfcae028f34
sha512=b74f883d8fad95738b7dd9b51f23af27ef1b541939ad9b8ea65cfb0d48a217c2265ca9319e9355c7782bf223a5168ee4ff236677503afa301c8b7b08561fcd8c
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)"
>