package html_of_jsx
Render HTML writing JSX
Install
Dune Dependency
Authors
Maintainers
Sources
html_of_jsx-0.0.1.tbz
sha256=d1a36abcbebd23adfaffe9eed27e69045c1e112da17bfebc385355d2a64f1fb7
sha512=bee674151f2ab6fba41acc1234118b5eca5379aedab2907da517bdeb604ddd02807519b9b29b4eea09595ced9936300b9a6ebf16c9edd92d959151daab4e7a96
doc/src/html_of_jsx.lib/Jsx.ml.html
Source file Jsx.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 35 36 37 38 39 40 41 42 43 44 45 46
module Attribute = struct (** Used internally, no need to use *) type t = | Bool of (string * bool) | String of (string * string) | Style of string | Event of (string * string) let t_to_string attr = match attr with (* false attributes don't get rendered *) | Bool (_, false) -> "" (* true attributes render solely the attribute name *) | Bool (k, true) -> k | Style styles -> Printf.sprintf "style=\"%s\"" styles | Event (name, value) -> Printf.sprintf "%s=\"%s\"" name value | String (k, v) -> Printf.sprintf "%s=\"%s\"" k (Html.encode v) let to_string attrs = match List.map t_to_string attrs with | [] -> "" | rest -> " " ^ (rest |> List.rev |> String.concat " " |> String.trim) end type node = { tag : string; attributes : Attribute.t list; children : element list; } and element = | Null | Text of string | Fragment of element list | Node of node | Component of (unit -> element) | List of element list let text txt = Text txt let null = Null let int i = Text (string_of_int i) let float f = Text (string_of_float f) let list arr = List arr let fragment arr = Fragment arr let node tag attributes children = Node { tag; attributes; children }
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>