-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cb92340
Showing
44 changed files
with
2,276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Debug (html_of_jsx.JSX.Debug)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../odoc.support/odoc.css"/><meta name="generator" content="odoc 2.4.3"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../odoc.support/highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">html_of_jsx</a> » <a href="../index.html">JSX</a> » Debug</nav><header class="odoc-preamble"><h1>Module <code><span>JSX.Debug</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type subst anchored" id="type-html_element"><a href="#type-html_element" class="anchor"></a><code><span><span class="keyword">type</span> html_element</span><span> := <a href="../index.html#type-element">element</a></span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-element"><a href="#type-element" class="anchor"></a><code><span><span class="keyword">type</span> element</span><span> = </span></code><ol><li id="type-element.Null" class="def variant constructor anchored"><a href="#type-element.Null" class="anchor"></a><code><span>| </span><span><span class="constructor">Null</span></span></code></li><li id="type-element.String" class="def variant constructor anchored"><a href="#type-element.String" class="anchor"></a><code><span>| </span><span><span class="constructor">String</span> <span class="keyword">of</span> string</span></code></li><li id="type-element.Unsafe" class="def variant constructor anchored"><a href="#type-element.Unsafe" class="anchor"></a><code><span>| </span><span><span class="constructor">Unsafe</span> <span class="keyword">of</span> string</span></code></li><li id="type-element.Node" class="def variant constructor anchored"><a href="#type-element.Node" class="anchor"></a><code><span>| </span><span><span class="constructor">Node</span> <span class="keyword">of</span> </span><span>{</span></code><ol><li id="type-element.tag" class="def record field anchored"><a href="#type-element.tag" class="anchor"></a><code><span>tag : string;</span></code></li><li id="type-element.attributes" class="def record field anchored"><a href="#type-element.attributes" class="anchor"></a><code><span>attributes : <span><a href="../index.html#type-attribute">attribute</a> list</span>;</span></code></li><li id="type-element.children" class="def record field anchored"><a href="#type-element.children" class="anchor"></a><code><span>children : <span><a href="#type-element">element</a> list</span>;</span></code></li></ol><code><span>}</span></code></li><li id="type-element.List" class="def variant constructor anchored"><a href="#type-element.List" class="anchor"></a><code><span>| </span><span><span class="constructor">List</span> <span class="keyword">of</span> <span><a href="#type-element">element</a> list</span></span></code></li></ol></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-view"><a href="#val-view" class="anchor"></a><code><span><span class="keyword">val</span> view : <span><a href="#type-html_element">html_element</a> <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>A function to inspect a JSX.element.</p><p>This function allows you to convert a JSX.element to its debuggable representation, which can be helpful for inspecting and debugging the structure of the element.</p><pre class="language-ocaml"><code>let debug: JSX.Debug.element = | ||
JSX.Debug.view( | ||
<div> | ||
<h1> {JSX.string("Hello, World!")} </h1> | ||
</div> | ||
); | ||
|
||
match debug with | ||
| JSX.Debug.Node {tag; attributes; children} -> Printf.printf("Node: %s", tag) | ||
| _ -> ()</code></pre></div></div></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Html (html_of_jsx.JSX.Html)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../odoc.support/odoc.css"/><meta name="generator" content="odoc 2.4.3"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../odoc.support/highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">html_of_jsx</a> » <a href="../index.html">JSX</a> » Html</nav><header class="odoc-preamble"><h1>Module <code><span>JSX.Html</span></code></h1><p>Used internally, no need to use</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-is_self_closing_tag"><a href="#val-is_self_closing_tag" class="anchor"></a><code><span><span class="keyword">val</span> is_self_closing_tag : <span>string <span class="arrow">-></span></span> bool</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-escape_and_add"><a href="#val-escape_and_add" class="anchor"></a><code><span><span class="keyword">val</span> escape_and_add : <span><span class="xref-unresolved">Stdlib</span>.Buffer.t <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_html_element"><a href="#val-is_html_element" class="anchor"></a><code><span><span class="keyword">val</span> is_html_element : <span>string <span class="arrow">-></span></span> bool</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_svg_element"><a href="#val-is_svg_element" class="anchor"></a><code><span><span class="keyword">val</span> is_svg_element : <span>string <span class="arrow">-></span></span> bool</span></code></div></div></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>JSX (html_of_jsx.JSX)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../odoc.support/odoc.css"/><meta name="generator" content="odoc 2.4.3"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../odoc.support/highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../index.html">html_of_jsx</a> » JSX</nav><header class="odoc-preamble"><h1>Module <code><span>JSX</span></code></h1><p>JSX module</p><p>The JSX module provides a set of functions and types to create and render HTML elements in a declarative manner, similar to JSX in JavaScript/React.</p><pre class="language-ocaml"><code>let html: string = JSX.render ( | ||
<div> | ||
<h1> {JSX.string("Hello, World!")} </h1> | ||
</div> | ||
)</code></pre></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-attribute"><a href="#type-attribute" class="anchor"></a><code><span><span class="keyword">type</span> attribute</span><span> = | ||
string | ||
* <span>[ <span>`Bool of bool</span> <span><span>| `Int</span> of int</span> <span><span>| `Float</span> of float</span> <span><span>| `String</span> of string</span> ]</span></span></code></div><div class="spec-doc"><p>Represents an attribute of an HTML element. It consists of a name and a value which can be of several types.</p><p>This is used by the ppx to create the attributes of the HTML element, and rarely used directly.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-element"><a href="#type-element" class="anchor"></a><code><span><span class="keyword">type</span> element</span></code></div><div class="spec-doc"><p>The type that represents a JSX.element</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-render"><a href="#val-render" class="anchor"></a><code><span><span class="keyword">val</span> render : <span><a href="#type-element">element</a> <span class="arrow">-></span></span> string</span></code></div><div class="spec-doc"><p>Render a JSX.element to a string.</p><p>This function takes a JSX.element and converts it into its corresponding HTML string representation.</p><pre class="language-ocaml"><code>let html: string = JSX.render ( | ||
<div> | ||
<h1> {JSX.string("Hello, World!")} </h1> | ||
</div> | ||
)</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-float"><a href="#val-float" class="anchor"></a><code><span><span class="keyword">val</span> float : <span>float <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>Helper to render a float.</p><p>This function helps in rendering a float value as a JSX element.</p><pre class="language-ocaml"><code>let element: JSX.element = JSX.float 3.14</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-fragment"><a href="#val-fragment" class="anchor"></a><code><span><span class="keyword">val</span> fragment : <span><span><a href="#type-element">element</a> list</span> <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> Use JSX.list instead</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-int"><a href="#val-int" class="anchor"></a><code><span><span class="keyword">val</span> int : <span>int <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>Helper to render an integer.</p><p>This function helps in rendering an integer value as a JSX element.</p><pre class="language-ocaml"><code>let element: JSX.element = JSX.int 42</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-list"><a href="#val-list" class="anchor"></a><code><span><span class="keyword">val</span> list : <span><span><a href="#type-element">element</a> list</span> <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>Helper to render a list of elements.</p><p>This function takes a list of JSX elements and returns a single JSX element that contains all of them. This is useful for rendering dynamic lists of elements.</p><pre class="language-ocaml"><code>let element: JSX.element = JSX.list [ | ||
JSX.string "Item 1"; | ||
JSX.string "Item 2"; | ||
JSX.string "Item 3" | ||
]</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-node"><a href="#val-node" class="anchor"></a><code><span><span class="keyword">val</span> node : <span>string <span class="arrow">-></span></span> <span><span><a href="#type-attribute">attribute</a> list</span> <span class="arrow">-></span></span> <span><span><a href="#type-element">element</a> list</span> <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>The function to create an HTML DOM Node.</p><p>It takes a tag name, a list of attributes, and a list of child elements to create an HTML node.</p><pre class="language-ocaml"><code>let link: JSX.element = JSX.node( | ||
"a", | ||
[("href", `String "https://ocaml.org")], | ||
[JSX.string "OCaml"] | ||
)</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-null"><a href="#val-null" class="anchor"></a><code><span><span class="keyword">val</span> null : <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>Helper to represent nullability in JSX.</p><p>This is useful to represent and pattern match against null or empty elements.</p><pre class="language-ocaml"><code>let element: JSX.element = JSX.null</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-string"><a href="#val-string" class="anchor"></a><code><span><span class="keyword">val</span> string : <span>string <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>Helper to represent an element as a string.</p><p>This function allows you to directly render a string as a JSX element.</p><pre class="language-ocaml"><code>let element: JSX.element = JSX.string "Hello, World!"</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-text"><a href="#val-text" class="anchor"></a><code><span><span class="keyword">val</span> text : <span>string <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>A deprecated function to render a text string.</p><p>This function is deprecated in favor of <code>JSX.string</code>.</p><pre class="language-ocaml"><code>let element: JSX.element = JSX.text "Hello, World!"</code></pre><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> Use JSX.string instead</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unsafe"><a href="#val-unsafe" class="anchor"></a><code><span><span class="keyword">val</span> unsafe : <span>string <span class="arrow">-></span></span> <a href="#type-element">element</a></span></code></div><div class="spec-doc"><p>Helper to bypass HTML encoding and treat output as unsafe. This can lead to HTML escaping problems, XSS injections, and other security concerns. Use with caution.</p><p>A common use case for bypassing the HTML encoding is to render a script o style tag.</p><pre class="language-ocaml"><code>let content: string = "Raw HTML" in | ||
let script: JSX.element = <script> content </script></code></pre></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Debug"><a href="#module-Debug" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Debug/index.html">Debug</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Html"><a href="#module-Html" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Html/index.html">Html</a></span><span> : <span class="keyword">module</span> <span class="keyword">type</span> <span class="keyword">of</span> <a href="Html/index.html">Html</a></span></code></div><div class="spec-doc"><p>Used internally, no need to use</p></div></div></div></body></html> |
Oops, something went wrong.