WIP on docs

This commit is contained in:
Daniel J. Summers 2025-01-23 20:17:51 -05:00
parent 7b5912e5e2
commit cede486099
5 changed files with 404 additions and 240 deletions

View File

@ -11,15 +11,16 @@ let internal toJson (pairs: (string * string) list) =
|> String.concat ", " |> String.concat ", "
|> sprintf "{ %s }" |> sprintf "{ %s }"
/// <summary>Convert a boolean to lowercase <tt>true</tt> or <tt>false</tt></summary> /// <summary>Convert a boolean to lowercase "true" or "false"</summary>
/// <param name="boolValue">The boolean value to convert</param> /// <param name="boolValue">The boolean value to convert</param>
/// <returns>"true" for <tt>true</tt>, "false" for <tt>false</tt></returns> /// <returns>"true" for <c>true</c>, "false" for <c>false</c></returns>
let internal toLowerBool (boolValue: bool) = let internal toLowerBool (boolValue: bool) =
(string boolValue).ToLowerInvariant() (string boolValue).ToLowerInvariant()
/// <summary>Valid values for the <tt>hx-swap</tt> attribute / <tt>HX-Reswap</tt> header</summary> /// <summary>Valid values for the <c>hx-swap</c> attribute / <c>HX-Reswap</c> header</summary>
/// <remarks>May be combined with <tt>swap</tt> / <tt>settle</tt> / <tt>scroll</tt> / <tt>show</tt> config)</remarks> /// <remarks>May be combined with <c>swap</c> / <c>settle</c> / <c>scroll</c> / <c>show</c> config)</remarks>
/// <seealso href="https://htmx.org/attributes/hx-swap/">Documentation</seealso>
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module HxSwap = module HxSwap =

View File

@ -11,7 +11,7 @@ let private hdr (headers : IHeaderDictionary) hdr =
/// Extensions to the header dictionary /// Extensions to the header dictionary
type IHeaderDictionary with type IHeaderDictionary with
/// <summary>Indicates that the request is via an element using <tt>hx-boost</tt></summary> /// <summary>Indicates that the request is via an element using <c>hx-boost</c></summary>
member this.HxBoosted member this.HxBoosted
with get () = hdr this "HX-Boosted" |> Option.map bool.Parse with get () = hdr this "HX-Boosted" |> Option.map bool.Parse
@ -19,29 +19,27 @@ type IHeaderDictionary with
member this.HxCurrentUrl member this.HxCurrentUrl
with get () = hdr this "HX-Current-URL" |> Option.map Uri with get () = hdr this "HX-Current-URL" |> Option.map Uri
/// <summary> /// <summary><c>true</c> if the request is for history restoration after a miss in the local history cache</summary>
/// <tt>true</tt> if the request is for history restoration after a miss in the local history cache
/// </summary>
member this.HxHistoryRestoreRequest member this.HxHistoryRestoreRequest
with get () = hdr this "HX-History-Restore-Request" |> Option.map bool.Parse with get () = hdr this "HX-History-Restore-Request" |> Option.map bool.Parse
/// <summary>The user response to an <tt>hx-prompt</tt></summary> /// <summary>The user response to an <c>hx-prompt</c></summary>
member this.HxPrompt member this.HxPrompt
with get () = hdr this "HX-Prompt" with get () = hdr this "HX-Prompt"
/// <summary><tt>true</tt> if the request came from htmx</summary> /// <summary><c>true</c> if the request came from htmx</summary>
member this.HxRequest member this.HxRequest
with get () = hdr this "HX-Request" |> Option.map bool.Parse with get () = hdr this "HX-Request" |> Option.map bool.Parse
/// <summary>The <tt>id</tt> attribute of the target element if it exists</summary> /// <summary>The <c>id</c> attribute of the target element if it exists</summary>
member this.HxTarget member this.HxTarget
with get () = hdr this "HX-Target" with get () = hdr this "HX-Target"
/// <summary>The <tt>id</tt> attribute of the triggered element if it exists</summary> /// <summary>The <c>id</c> attribute of the triggered element if it exists</summary>
member this.HxTrigger member this.HxTrigger
with get () = hdr this "HX-Trigger" with get () = hdr this "HX-Trigger"
/// <summary>The <tt>name</tt> attribute of the triggered element if it exists</summary> /// <summary>The <c>name</c> attribute of the triggered element if it exists</summary>
member this.HxTriggerName member this.HxTriggerName
with get () = hdr this "HX-Trigger-Name" with get () = hdr this "HX-Trigger-Name"
@ -64,99 +62,111 @@ module Handlers =
open Giraffe.Htmx.Common open Giraffe.Htmx.Common
/// <summary>Instruct htmx to perform a client-side redirect for content</summary>
/// <param name="path">The path where the content should be found</param>
/// <returns>An HTTP handler with the <c>HX-Location</c> header set</returns>
/// <seealso href="https://htmx.org/headers/hx-location/">Documentation</seealso>
let withHxLocation (path: string) : HttpHandler =
setHttpHeader "HX-Location" path
/// <summary>Pushes a new url into the history stack</summary> /// <summary>Pushes a new url into the history stack</summary>
/// <param name="url">The URL to be pushed</param> /// <param name="url">The URL to be pushed</param>
/// <returns>An HTTP handler with the <tt>HX-Push-Url</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Push-Url</c> header set</returns>
/// <remarks>Use <see cref="withHxNoPushUrl" /> to explicitly not push a new URL</remarks>
/// <seealso href="https://htmx.org/headers/hx-push-url/">Documentation</seealso>
let withHxPushUrl (url: string) : HttpHandler = let withHxPushUrl (url: string) : HttpHandler =
setHttpHeader "HX-Push-Url" url setHttpHeader "HX-Push-Url" url
/// <summary>Explicitly do not push a new URL into the history stack</summary> /// <summary>Explicitly do not push a new URL into the history stack</summary>
/// <returns>An HTTP handler with the <tt>HX-Push-Url</tt> header set to <tt>false</tt></returns> /// <returns>An HTTP handler with the <c>HX-Push-Url</c> header set to <c>false</c></returns>
/// <seealso href="https://htmx.org/headers/hx-push-url/">Documentation</seealso>
let withHxNoPushUrl : HttpHandler = let withHxNoPushUrl : HttpHandler =
toLowerBool false |> withHxPushUrl toLowerBool false |> withHxPushUrl
/// Pushes a new url into the history stack
[<Obsolete "Use withHxPushUrl; HX-Push was replaced by HX-Push-Url in v1.8.0">]
let withHxPush = withHxPushUrl
/// Explicitly do not push a new URL into the history stack
[<Obsolete "Use withHxNoPushUrl; HX-Push was replaced by HX-Push-Url in v1.8.0">]
let withHxNoPush = withHxNoPushUrl
/// <summary>Can be used to do a client-side redirect to a new location</summary> /// <summary>Can be used to do a client-side redirect to a new location</summary>
/// <param name="url">The URL to which the client should be redirected</param> /// <param name="url">The URL to which the client should be redirected</param>
/// <returns>An HTTP handler with the <tt>HX-Redirect</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Redirect</c> header set</returns>
/// <seealso href="https://htmx.org/headers/hx-redirect/">Documentation</seealso>
let withHxRedirect (url: string) : HttpHandler = let withHxRedirect (url: string) : HttpHandler =
setHttpHeader "HX-Redirect" url setHttpHeader "HX-Redirect" url
/// <summary>If set to <tt>true</tt> the client side will do a full refresh of the page</summary> /// <summary>If set to <c>true</c> the client side will do a full refresh of the page</summary>
/// <param name="shouldRefresh">Whether the client should refresh their page</param> /// <param name="shouldRefresh">Whether the client should refresh their page</param>
/// <returns>An HTTP handler with the <tt>HX-Refresh</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Refresh</c> header set</returns>
let withHxRefresh shouldRefresh : HttpHandler = let withHxRefresh shouldRefresh : HttpHandler =
(toLowerBool >> setHttpHeader "HX-Refresh") shouldRefresh (toLowerBool >> setHttpHeader "HX-Refresh") shouldRefresh
/// <summary>Replaces the current URL in the history stack</summary> /// <summary>Replaces the current URL in the history stack</summary>
/// <param name="url">The URL to place in the history stack in place of the current one</param> /// <param name="url">The URL to place in the history stack in place of the current one</param>
/// <returns>An HTTP handler with the <tt>HX-Replace-URL</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Replace-URL</c> header set</returns>
/// <remarks>Use <see cref="withHxNoRelaceUrl" /> to explicitly not replace the current URL</remarks>
/// <seealso href="https://htmx.org/headers/hx-replace-url/">Documentation</seealso>
let withHxReplaceUrl url : HttpHandler = let withHxReplaceUrl url : HttpHandler =
setHttpHeader "HX-Replace-Url" url setHttpHeader "HX-Replace-Url" url
/// <summary>Explicitly do not replace the current URL in the history stack</summary> /// <summary>Explicitly do not replace the current URL in the history stack</summary>
/// <returns>An HTTP handler with the <tt>HX-Replace-URL</tt> header set to <tt>false</tt></returns> /// <returns>An HTTP handler with the <c>HX-Replace-URL</c> header set to <c>false</c></returns>
/// <seealso href="https://htmx.org/headers/hx-replace-url/">Documentation</seealso>
let withHxNoReplaceUrl : HttpHandler = let withHxNoReplaceUrl : HttpHandler =
toLowerBool false |> withHxReplaceUrl toLowerBool false |> withHxReplaceUrl
/// <summary>Override which portion of the response will be swapped into the target document</summary> /// <summary>Override which portion of the response will be swapped into the target document</summary>
/// <param name="target">The selector for the new response target</param> /// <param name="target">The selector for the new response target</param>
/// <returns>An HTTP handler with the <tt>HX-Reselect</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Reselect</c> header set</returns>
let withHxReselect (target: string) : HttpHandler = let withHxReselect (target: string) : HttpHandler =
setHttpHeader "HX-Reselect" target setHttpHeader "HX-Reselect" target
/// <summary>Override the <tt>hx-swap</tt> attribute from the initiating element</summary> /// <summary>Override the <c>hx-swap</c> attribute from the initiating element</summary>
/// <param name="swap">The swap value to override</param> /// <param name="swap">The swap value to override</param>
/// <returns>An HTTP handler with the <tt>HX-Reswap</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Reswap</c> header set</returns>
/// <remarks>Use <see cref="T:Giraffe.Htmx.Common.HxSwap">HxSwap</see> constants for best results</remarks> /// <remarks>Use <see cref="T:Giraffe.Htmx.Common.HxSwap">HxSwap</see> constants for best results</remarks>
let withHxReswap (swap: string) : HttpHandler = let withHxReswap (swap: string) : HttpHandler =
setHttpHeader "HX-Reswap" swap setHttpHeader "HX-Reswap" swap
/// <summary>Allows you to override the <tt>hx-target</tt> attribute</summary> /// <summary>Allows you to override the <c>hx-target</c> attribute</summary>
/// <param name="target">The new target for the response</param> /// <param name="target">The new target for the response</param>
/// <returns>An HTTP handler with the <tt>HX-Retarget</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Retarget</c> header set</returns>
let withHxRetarget (target: string) : HttpHandler = let withHxRetarget (target: string) : HttpHandler =
setHttpHeader "HX-Retarget" target setHttpHeader "HX-Retarget" target
/// <summary>Allows you to trigger a single client side event</summary> /// <summary>Allows you to trigger a single client side event</summary>
/// <param name="evt">The call to the event that should be triggered</param> /// <param name="evt">The call to the event that should be triggered</param>
/// <returns>An HTTP handler with the <tt>HX-Trigger</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Trigger</c> header set</returns>
/// <seealso href="https://htmx.org/headers/hx-trigger/">Documentation</seealso>
let withHxTrigger (evt: string) : HttpHandler = let withHxTrigger (evt: string) : HttpHandler =
setHttpHeader "HX-Trigger" evt setHttpHeader "HX-Trigger" evt
/// <summary>Allows you to trigger multiple client side events</summary> /// <summary>Allows you to trigger multiple client side events</summary>
/// <param name="evts">The calls to events that should be triggered</param> /// <param name="evts">The calls to events that should be triggered</param>
/// <returns>An HTTP handler with the <tt>HX-Trigger</tt> header set for all given events</returns> /// <returns>An HTTP handler with the <c>HX-Trigger</c> header set for all given events</returns>
/// <seealso href="https://htmx.org/headers/hx-trigger/">Documentation</seealso>
let withHxTriggerMany evts : HttpHandler = let withHxTriggerMany evts : HttpHandler =
toJson evts |> setHttpHeader "HX-Trigger" toJson evts |> setHttpHeader "HX-Trigger"
/// <summary>Allows you to trigger a single client side event after changes have settled</summary> /// <summary>Allows you to trigger a single client side event after changes have settled</summary>
/// <param name="evt">The call to the event that should be triggered</param> /// <param name="evt">The call to the event that should be triggered</param>
/// <returns>An HTTP handler with the <tt>HX-Trigger-After-Settle</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Trigger-After-Settle</c> header set</returns>
/// <seealso href="https://htmx.org/headers/hx-trigger/">Documentation</seealso>
let withHxTriggerAfterSettle (evt: string) : HttpHandler = let withHxTriggerAfterSettle (evt: string) : HttpHandler =
setHttpHeader "HX-Trigger-After-Settle" evt setHttpHeader "HX-Trigger-After-Settle" evt
/// <summary>Allows you to trigger multiple client side events after changes have settled</summary> /// <summary>Allows you to trigger multiple client side events after changes have settled</summary>
/// <param name="evts">The calls to events that should be triggered</param> /// <param name="evts">The calls to events that should be triggered</param>
/// <returns>An HTTP handler with the <tt>HX-Trigger-After-Settle</tt> header set for all given events</returns> /// <returns>An HTTP handler with the <c>HX-Trigger-After-Settle</c> header set for all given events</returns>
/// <seealso href="https://htmx.org/headers/hx-trigger/">Documentation</seealso>
let withHxTriggerManyAfterSettle evts : HttpHandler = let withHxTriggerManyAfterSettle evts : HttpHandler =
toJson evts |> setHttpHeader "HX-Trigger-After-Settle" toJson evts |> setHttpHeader "HX-Trigger-After-Settle"
/// <summary>Allows you to trigger a single client side event after DOM swapping occurs</summary> /// <summary>Allows you to trigger a single client side event after DOM swapping occurs</summary>
/// <param name="evt">The call to the event that should be triggered</param> /// <param name="evt">The call to the event that should be triggered</param>
/// <returns>An HTTP handler with the <tt>HX-Trigger-After-Swap</tt> header set</returns> /// <returns>An HTTP handler with the <c>HX-Trigger-After-Swap</c> header set</returns>
/// <seealso href="https://htmx.org/headers/hx-trigger/">Documentation</seealso>
let withHxTriggerAfterSwap (evt: string) : HttpHandler = let withHxTriggerAfterSwap (evt: string) : HttpHandler =
setHttpHeader "HX-Trigger-After-Swap" evt setHttpHeader "HX-Trigger-After-Swap" evt
/// <summary>Allows you to trigger multiple client side events after DOM swapping occurs</summary> /// <summary>Allows you to trigger multiple client side events after DOM swapping occurs</summary>
/// <param name="evts">The calls to events that should be triggered</param> /// <param name="evts">The calls to events that should be triggered</param>
/// <returns>An HTTP handler with the <tt>HX-Trigger-After-Swap</tt> header set for all given events</returns> /// <returns>An HTTP handler with the <c>HX-Trigger-After-Swap</c> header set for all given events</returns>
/// <seealso href="https://htmx.org/headers/hx-trigger/">Documentation</seealso>
let withHxTriggerManyAfterSwap evts : HttpHandler = let withHxTriggerManyAfterSwap evts : HttpHandler =
toJson evts |> setHttpHeader "HX-Trigger-After-Swap" toJson evts |> setHttpHeader "HX-Trigger-After-Swap"

View File

@ -207,6 +207,14 @@ let next (ctx : HttpContext) = Task.FromResult (Some ctx)
/// Tests for the HttpHandler functions provided in the Handlers module /// Tests for the HttpHandler functions provided in the Handlers module
let handlers = let handlers =
testList "HandlerTests" [ testList "HandlerTests" [
testTask "withHxLocation succeeds" {
let ctx = Substitute.For<HttpContext>()
let dic = HeaderDictionary()
ctx.Response.Headers.ReturnsForAnyArgs dic |> ignore
let! _ = withHxLocation "/pagina-otro.html" next ctx
Expect.isTrue (dic.ContainsKey "HX-Location") "The HX-Location header should be present"
Expect.equal dic["HX-Location"].[0] "/pagina-otro.html" "The HX-Location value was incorrect"
}
testTask "withHxPushUrl succeeds" { testTask "withHxPushUrl succeeds" {
let ctx = Substitute.For<HttpContext>() let ctx = Substitute.For<HttpContext>()
let dic = HeaderDictionary() let dic = HeaderDictionary()

View File

@ -406,8 +406,8 @@ let hxEvent =
Expect.equal (XhrProgress.ToHxOnString()) "xhr:progress" "XhrProgress hx-on event name not correct" Expect.equal (XhrProgress.ToHxOnString()) "xhr:progress" "XhrProgress hx-on event name not correct"
} }
] ]
] ]
/// Tests for the HxHeaders module /// Tests for the HxHeaders module
let hxHeaders = let hxHeaders =
testList "HxHeaders" [ testList "HxHeaders" [
@ -726,7 +726,7 @@ let attributes =
|> shouldRender """<figure hx-headers="{ &quot;X-Special-Header&quot;: &quot;some-header&quot; }"></figure>""" |> shouldRender """<figure hx-headers="{ &quot;X-Special-Header&quot;: &quot;some-header&quot; }"></figure>"""
} }
test "_hxHistory succeeds" { test "_hxHistory succeeds" {
span [ _hxHistory "false" ] [] |> shouldRender """<span hx-history="false"></span>""" span [ _hxHistory false ] [] |> shouldRender """<span hx-history="false"></span>"""
} }
test "_hxHistoryElt succeeds" { test "_hxHistoryElt succeeds" {
table [ _hxHistoryElt ] [] |> shouldRender """<table hx-history-elt></table>""" table [ _hxHistoryElt ] [] |> shouldRender """<table hx-history-elt></table>"""

View File

@ -1,7 +1,7 @@
/// <summary>Types and functions supporting htmx attributes in Giraffe View Engine</summary> /// <summary>Types and functions supporting htmx attributes in Giraffe View Engine</summary>
module Giraffe.ViewEngine.Htmx module Giraffe.ViewEngine.Htmx
/// <summary>Valid values for the <tt>hx-encoding</tt> attribute</summary> /// <summary>Valid values for the <c>hx-encoding</c> attribute</summary>
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module HxEncoding = module HxEncoding =
@ -195,11 +195,11 @@ type HxEvent =
/// <summary>The htmx event name</summary> /// <summary>The htmx event name</summary>
override this.ToString() = fst HxEvent.Values[this] override this.ToString() = fst HxEvent.Values[this]
/// <summary>The <tt>hx-on</tt> variant of the htmx event name</summary> /// <summary>The <c>hx-on</c> variant of the htmx event name</summary>
member this.ToHxOnString() = snd HxEvent.Values[this] member this.ToHxOnString() = snd HxEvent.Values[this]
/// <summary>Helper to create the <tt>hx-headers</tt> attribute</summary> /// <summary>Helper to create the <c>hx-headers</c> attribute</summary>
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module HxHeaders = module HxHeaders =
@ -207,7 +207,8 @@ module HxHeaders =
let From = Giraffe.Htmx.Common.toJson let From = Giraffe.Htmx.Common.toJson
/// <summary>Values / helpers for the <tt>hx-params</tt> attribute</summary> /// <summary>Values / helpers for the <c>hx-params</c> attribute</summary>
/// <seealso href="https://htmx.org/attributes/hx-params/">Documentation</seealso>
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module HxParams = module HxParams =
@ -219,18 +220,19 @@ module HxParams =
/// <summary>Include the specified parameters</summary> /// <summary>Include the specified parameters</summary>
/// <param name="fields">One or more fields to include in the request</param> /// <param name="fields">One or more fields to include in the request</param>
/// <returns>The list of fields for the <tt>hx-params</tt> attribute value</returns> /// <returns>The list of fields for the <c>hx-params</c> attribute value</returns>
let With fields = let With fields =
match fields with [] -> "" | _ -> fields |> List.reduce (fun acc it -> $"{acc},{it}") match fields with [] -> "" | _ -> fields |> List.reduce (fun acc it -> $"{acc},{it}")
/// <summary>Exclude the specified parameters</summary> /// <summary>Exclude the specified parameters</summary>
/// <param name="fields">One or more fields to exclude from the request</param> /// <param name="fields">One or more fields to exclude from the request</param>
/// <returns>The list of fields for the <tt>hx-params</tt> attribute value prefixed with "not"</returns> /// <returns>The list of fields for the <c>hx-params</c> attribute value prefixed with "not"</returns>
let Except fields = let Except fields =
With fields |> sprintf "not %s" With fields |> sprintf "not %s"
/// <summary>Helpers to define <tt>hx-request</tt> attribute values</summary> /// <summary>Helpers to define <c>hx-request</c> attribute values</summary>
/// <seealso href="https://htmx.org/attributes/hx-request/">Documentation</seealso>
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module HxRequest = module HxRequest =
@ -251,21 +253,21 @@ module HxRequest =
$"\"timeout\": {ms}" $"\"timeout\": {ms}"
/// <summary>Include or exclude credentials from the request</summary> /// <summary>Include or exclude credentials from the request</summary>
/// <param name="send"><tt>true</tt> if credentials should be sent, <tt>false</tt> if not</param> /// <param name="send"><c>true</c> if credentials should be sent, <c>false</c> if not</param>
/// <returns>A string with the configured credential options</returns> /// <returns>A string with the configured credential options</returns>
let Credentials send = let Credentials send =
(toLowerBool >> sprintf "\"credentials\": %s") send (toLowerBool >> sprintf "\"credentials\": %s") send
/// <summary>Exclude or include headers from the request</summary> /// <summary>Exclude or include headers from the request</summary>
/// <param name="exclude"> /// <param name="exclude">
/// <tt>true</tt> if no headers should be sent; <tt>false</tt> if headers should be sent /// <c>true</c> if no headers should be sent; <c>false</c> if headers should be sent
/// </param> /// </param>
/// <returns>A string with the configured header options</returns> /// <returns>A string with the configured header options</returns>
let NoHeaders exclude = let NoHeaders exclude =
(toLowerBool >> sprintf "\"noHeaders\": %s") exclude (toLowerBool >> sprintf "\"noHeaders\": %s") exclude
/// Helpers for the `hx-trigger` attribute /// <summary>Helpers for the <c>hx-trigger</c> attribute</summary>
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module HxTrigger = module HxTrigger =
@ -366,7 +368,8 @@ module HxTrigger =
let QueueNone = Queue "none" let QueueNone = Queue "none"
/// <summary>Helper to create the `hx-vals` attribute</summary> /// <summary>Helper to create the <c>hx-vals</c> attribute</summary>
/// <seealso href="https://htmx.org/attributes/hx-vals/">Documentation</seealso>
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module HxVals = module HxVals =
@ -374,149 +377,291 @@ module HxVals =
let From = Giraffe.Htmx.Common.toJson let From = Giraffe.Htmx.Common.toJson
open Giraffe.Htmx
/// <summary>Attributes and flags for htmx</summary> /// <summary>Attributes and flags for htmx</summary>
[<AutoOpen>] [<AutoOpen>]
module HtmxAttrs = module HtmxAttrs =
/// <summary>Progressively enhances anchors and forms to use AJAX requests</summary> /// <summary>Progressively enhances anchors and forms to use AJAX requests</summary>
/// <remarks>Use <tt>_hxNoBoost</tt> to set to false</remarks> /// <remarks>Use <c>_hxNoBoost</c> to set to false</remarks>
/// <seealso href="https://htmx.org/attributes/hx-boost/">Documentation</seealso>
let _hxBoost = attr "hx-boost" "true" let _hxBoost = attr "hx-boost" "true"
/// <summary>Shows a <tt>confirm()</tt> dialog before issuing a request</summary> /// <summary>Shows a <c>confirm()</c> dialog before issuing a request</summary>
/// <param name="prompt">The prompt to present to the user when seeking their confirmation</param> /// <param name="prompt">The prompt to present to the user when seeking their confirmation</param>
/// <returns>A configured <tt>hx-confirm</tt> attribute</returns> /// <returns>A configured <c>hx-confirm</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-confirm/">Documentation</seealso>
let _hxConfirm prompt = let _hxConfirm prompt =
attr "hx-confirm" prompt attr "hx-confirm" prompt
/// <summary>Issues a <tt>DELETE</tt> to the specified URL</summary> /// <summary>Issues a <c>DELETE</c> to the specified URL</summary>
/// <param name="url">The URL to which the <tt>DELETE</tt> request should be sent</param> /// <param name="url">The URL to which the <c>DELETE</c> request should be sent</param>
/// <returns>A configured <tt>hx-delete</tt> attribute</returns> /// <returns>A configured <c>hx-delete</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-delete/">Documentation</seealso>
let _hxDelete url = let _hxDelete url =
attr "hx-delete" url attr "hx-delete" url
/// <summary>Disables htmx processing for the given node and any children nodes</summary> /// <summary>Disables htmx processing for the given node and any children nodes</summary>
/// <seealso href="https://htmx.org/attributes/hx-disable/">Documentation</seealso>
let _hxDisable = flag "hx-disable" let _hxDisable = flag "hx-disable"
/// <summary>Specifies elements that should be disabled when an htmx request is in flight</summary> /// <summary>Specifies elements that should be disabled when an htmx request is in flight</summary>
/// <param name="elt">The element to disable when an htmx request is in flight</param> /// <param name="elt">The element to disable when an htmx request is in flight</param>
/// <returns>A configured <tt>hx-disabled-elt</tt> attribute</returns> /// <returns>A configured <c>hx-disabled-elt</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-disabled-elt/">Documentation</seealso>
let _hxDisabledElt elt = let _hxDisabledElt elt =
attr "hx-disabled-elt" elt attr "hx-disabled-elt" elt
/// <summary>Disinherit all ("*") or specific htmx attributes</summary> /// <summary>Disinherit all ("*") or specific htmx attributes</summary>
/// <param name="hxAttrs">The htmx attributes to disinherit (should start with "hx-")</param> /// <param name="hxAttrs">The htmx attributes to disinherit (should start with "hx-")</param>
/// <returns>A configured <tt>hx-disinherit</tt> attribute</returns> /// <returns>A configured <c>hx-disinherit</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-disinherit/">Documentation</seealso>
let _hxDisinherit hxAttrs = let _hxDisinherit hxAttrs =
attr "hx-disinherit" hxAttrs attr "hx-disinherit" hxAttrs
/// <summary>Changes the request encoding type</summary> /// <summary>Changes the request encoding type</summary>
/// <param name="enc">The encoding type (use <tt>HxEncoding</tt> constants)</param> /// <param name="enc">The encoding type (use <c>HxEncoding</c> constants)</param>
/// <returns>A configured <tt>hx-encoding</tt> attribute</returns> /// <returns>A configured <c>hx-encoding</c> attribute</returns>
/// <seealso cref="HxEncoding" />
/// <seealso href="https://htmx.org/attributes/hx-encoding/">Documentation</seealso>
let _hxEncoding enc = let _hxEncoding enc =
attr "hx-encoding" enc attr "hx-encoding" enc
/// <summary>Extensions to use for this element</summary> /// <summary>Extensions to use for this element</summary>
/// <param name="exts">A list of extensions to apply to this element</param> /// <param name="exts">A list of extensions to apply to this element</param>
/// <returns>A configured <tt>hx-ext</tt> attribute</returns> /// <returns>A configured <c>hx-ext</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-ext/">Documentation</seealso>
let _hxExt exts = let _hxExt exts =
attr "hx-ext" exts attr "hx-ext" exts
/// <summary>Issues a <tt>GET</tt> to the specified URL</summary> /// <summary>Issues a <c>GET</c> to the specified URL</summary>
/// <param name="url">The URL to which the <tt>GET</tt> request should be sent</param> /// <param name="url">The URL to which the <c>GET</c> request should be sent</param>
/// <returns>A configured <tt>hx-get</tt> attribute</returns> /// <returns>A configured <c>hx-get</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-get/">Documentation</seealso>
let _hxGet url = let _hxGet url =
attr "hx-get" url attr "hx-get" url
/// <summary>Adds to the headers that will be submitted with the request</summary> /// <summary>Adds to the headers that will be submitted with the request</summary>
[<System.Obsolete "Convert this parameter">] /// <param name="hdrs">The headers to include with the request</param>
let _hxHeaders = attr "hx-headers" /// <returns>A configured <c>hx-headers</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-headers/">Documentation</seealso>
let _hxHeaders hdrs =
attr "hx-headers" hdrs
/// <summary>
/// Set to "false" to prevent pages with sensitive information from being stored in the history cache /// Set to "false" to prevent pages with sensitive information from being stored in the history cache
let _hxHistory = attr "hx-history" /// </summary>
/// <param name="shouldStore">Whether the page should be stored in the history cache</param>
/// <returns>A configured <c>hx-history</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-history/">Documentation</seealso>
let _hxHistory shouldStore =
attr "hx-history" (toLowerBool shouldStore)
/// The element to snapshot and restore during history navigation /// <summary>The element to snapshot and restore during history navigation</summary>
let _hxHistoryElt = flag "hx-history-elt" /// <seealso href="https://htmx.org/attributes/hx-history-elt/">Documentation</seealso>
let _hxHistoryElt =
flag "hx-history-elt"
/// Includes additional data in AJAX requests /// <summary>Includes additional data in AJAX requests</summary>
let _hxInclude = attr "hx-include" /// <param name="spec">The specification of what should be included in the request</param>
/// <returns>A configured <c>hx-include</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-include/">Documentation</seealso>
let _hxInclude spec =
attr "hx-include" spec
/// The element to put the htmx-request class on during the AJAX request /// <summary>The element to put the <c>htmx-request</c> class on during the AJAX request</summary>
let _hxIndicator = attr "hx-indicator" /// <param name="selector">The selector for the indicator element</param>
/// <returns>A configured <c>hx-indicator</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-indicator/">Documentation</seealso>
let _hxIndicator selector =
attr "hx-indicator" selector
/// Overrides a previous `hx-boost` /// <summary>Overrides a previous <c>hx-boost</c> (hx-boost="false")</summary>
let _hxNoBoost = attr "hx-boost" "false" /// <seealso href="https://htmx.org/attributes/hx-boost/">Documentation</seealso>
let _hxNoBoost =
attr "hx-boost" "false"
/// Attach an event handler for DOM events /// <summary>Attach an event handler for DOM events</summary>
let _hxOnEvent evtName = /// <param name="evtName">The name of the event</param>
attr $"hx-on:%s{evtName}" /// <param name="handler">The script to be executed when the event occurs</param>
/// <returns>A configured <c>hx-on</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-on/">Documentation</seealso>
let _hxOnEvent evtName handler =
attr $"hx-on:%s{evtName}" handler
/// Attach an event handler for htmx events /// <summary>Attach an event handler for htmx events</summary>
let _hxOnHxEvent (hxEvent: HxEvent) = /// <param name="hxEvent">The <c>HxEvent</c> to be handled</param>
_hxOnEvent $":{hxEvent.ToHxOnString()}" /// <param name="handler">The script to be executed when the event occurs</param>
/// <returns>A configured <c>hx-on::</c> attribute</returns>
/// <seealso cref="HxEvent" />
/// <seealso href="https://htmx.org/attributes/hx-on/">Documentation</seealso>
let _hxOnHxEvent (hxEvent: HxEvent) handler =
_hxOnEvent $":{hxEvent.ToHxOnString()}" handler
/// Filters the parameters that will be submitted with a request /// <summary>Filters the parameters that will be submitted with a request</summary>
let _hxParams = attr "hx-params" /// <param name="toInclude">The fields to include (use <c>HxParams</c> to generate this value)</param>
/// <returns>A configured <c>hx-params</c> attribute</returns>
/// <seealso cref="HxParams" />
/// <seealso href="https://htmx.org/attributes/hx-params/">Documentation</seealso>
let _hxParams toInclude =
attr "hx-params" toInclude
/// Issues a PATCH to the specified URL /// <summary>Issues a <c>PATCH</c> to the specified URL</summary>
let _hxPatch = attr "hx-patch" /// <param name="url">The URL to which the request should be directed</param>
/// <returns>A configured <c>hx-patch</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-patch/">Documentation</seealso>
let _hxPatch url =
attr "hx-patch" url
/// Issues a POST to the specified URL /// <summary>Issues a <c>POST</c> to the specified URL</summary>
let _hxPost = attr "hx-post" /// <param name="url">The URL to which the request should be directed</param>
/// <returns>A configured <c>hx-post</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-post/">Documentation</seealso>
let _hxPost url =
attr "hx-post" url
/// Preserves an element between requests /// <summary>Preserves an element between requests</summary>
let _hxPreserve = attr "hx-preserve" "true" /// <seealso href="https://htmx.org/attributes/hx-preserve/">Documentation</seealso>
let _hxPreserve =
flag "hx-preserve"
/// Shows a prompt before submitting a request /// <summary>Shows a <c>prompt()</c> dialog before submitting a request</summary>
let _hxPrompt = attr "hx-prompt" /// <param name="text">The text for the prompt</param>
/// <returns>A configured <c>hx-prompt</c> attribute</returns>
/// <remarks>The value provided will be in the <c>HX-Prompt</c> request header</remarks>
/// <seealso href="https://htmx.org/attributes/hx-prompt/">Documentation</seealso>
let _hxPrompt text =
attr "hx-prompt" text
/// Pushes the URL into the location bar, creating a new history entry /// <summary>Pushes the URL into the location bar, creating a new history entry</summary>
let _hxPushUrl = attr "hx-push-url" /// <param name="spec">
/// <ul>
/// <li>"true" to push the fetched URL</li>
/// <li>"false" to explicitly not push the fetched URL</li>
/// <li>A specific URL to push</li>
/// </ul>
/// </param>
/// <returns>A configured <c>hx-push-url</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-push-url/">Documentation</seealso>
let _hxPushUrl spec =
attr "hx-push-url" spec
/// Issues a PUT to the specified URL /// <summary>Issues a <c>PUT</c> to the specified URL</summary>
let _hxPut = attr "hx-put" /// <param name="url">The URL to which the request should be directed</param>
/// <returns>A configured <c>hx-put</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-put/">Documentation</seealso>
let _hxPut url =
attr "hx-put" url
/// Replaces the current URL in the browser's history stack /// <summary>Replaces the current URL in the browser's history stack</summary>
let _hxReplaceUrl = attr "hx-replace-url" /// <param name="spec">
/// <ul>
/// <li>"true" to replace the current URL with the fetched one</li>
/// <li>"false" to explicitly replace nothing</li>
/// <li>A specific URL to replace in the browser's history</li>
/// </ul>
/// </param>
/// <returns>A configured <c>hx-replace-url</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-replace-url/">Documentation</seealso>
let _hxReplaceUrl spec =
attr "hx-replace-url" spec
/// Configures various aspects of the request /// <summary>Configures various aspects of the request</summary>
let _hxRequest = attr "hx-request" /// <param name="spec">The configuration spec (use <c>HxRequest.Configure</c> to create value)</param>
/// <returns>A configured <c>hx-request</c> attribute</returns>
/// <seealso cref="HxRequest.Configure" />
/// <seealso href="https://htmx.org/attributes/hx-request/">Documentation</seealso>
let _hxRequest spec =
attr "hx-request" spec
/// Selects a subset of the server response to process /// <summary>Selects a subset of the server response to process</summary>
let _hxSelect = attr "hx-select" /// <param name="selector">A CSS selector for the content to be selected</param>
/// <returns>A configured <c>hx-select</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-select/">Documentation</seealso>
let _hxSelect selector =
attr "hx-select" selector
/// Selects a subset of an out-of-band server response /// <summary>Selects a subset of an out-of-band server response</summary>
let _hxSelectOob = attr "hx-select-oob" /// <param name="selectors">One or more comma-delimited CSS selectors for the content to be selected</param>
/// <returns>A configured <c>hx-select-oob</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-select-oob/">Documentation</seealso>
let _hxSelectOob selectors =
attr "hx-select-oob" selectors
/// Controls how the response content is swapped into the DOM (e.g. 'outerHTML' or 'beforeEnd') /// <summary>
let _hxSwap = attr "hx-swap" /// Controls how the response content is swapped into the DOM (e.g. <c>outerHTML</c> or <c>beforeEnd</c>)
/// </summary>
/// <param name="swap">The type of swap to perform (use <c>HxSwap</c> values)</param>
/// <returns>A configured <c>hx-swap</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-swap/">Documentation</seealso>
let _hxSwap swap =
attr "hx-swap" swap
/// Controls how the response content is swapped into the DOM (e.g. 'outerHTML' or 'beforeEnd'), enabling CSS /// <summary>
/// transitions /// Controls how the response content is swapped into the DOM (e.g. <c>outerHTML</c> or <c>beforeEnd</c>), enabling
let _hxSwapWithTransition = sprintf "%s transition:true" >> _hxSwap /// CSS transitions
/// </summary>
/// <param name="swap">The type of swap to perform (use <c>HxSwap</c> values)</param>
/// <returns>A configured <c>hx-swap</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-swap/">Documentation</seealso>
let _hxSwapWithTransition swap =
_hxSwap $"%s{swap} transition:true"
/// <summary>
/// Marks content in a response as being "Out of Band", i.e. swapped somewhere other than the target /// Marks content in a response as being "Out of Band", i.e. swapped somewhere other than the target
let _hxSwapOob = attr "hx-swap-oob" /// </summary>
/// <param name="swap">
/// <ul>
/// <li>"true" to mark this as an OOB swap</li>
/// <li>Any <c>HxSwap</c> value</li>
/// <li>Any <c>HxSwap</c> value, followed by a colon (<c>:</c>) and a CSS selector</li>
/// </ul>
/// </param>
/// <returns>A configured <c>hx-swap-oob</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-swap-oob/">Documentation</seealso>
let _hxSwapOob swap =
attr "hx-swap-oob" swap
/// Synchronize events based on another element /// Synchronize events based on another element
let _hxSync = attr "hx-sync" let _hxSync = attr "hx-sync"
/// Specifies the target element to be swapped /// <summary>Specifies the target element to be swapped</summary>
let _hxTarget = attr "hx-target" /// <param name="selector">A CSS selector or relative reference (or both) to identify the target</param>
/// <returns>A configured <c>hx-target</c> attribute</returns>
/// <seealso href="https://htmx.org/attributes/hx-target/">Documentation</seealso>
let _hxTarget selector =
attr "hx-target" selector
/// Specifies the event that triggers the request /// Specifies the event that triggers the request
let _hxTrigger = attr "hx-trigger" let _hxTrigger = attr "hx-trigger"
/// Validate an input element (uses HTML5 validation API) /// <summary>Validate an input element (uses HTML5 validation API)</summary>
let _hxValidate = flag "hx-validate" /// <seealso href="https://htmx.org/attributes/hx-validate/">Documentation</seealso>
let _hxValidate =
flag "hx-validate"
/// Adds to the parameters that will be submitted with the request /// <summary>Adds to the parameters that will be submitted with the request</summary>
let _hxVals = attr "hx-vals" /// <param name="values">The values for the parameters (use <c>HxVals.From</c> to create)</param>
/// <returns>A configured <c>hx-vals</c> attribute</returns>
/// <seealso cref="HxVals.From" />
/// <seealso href="https://htmx.org/attributes/hx-vals/">Documentation</seealso>
let _hxVals values =
attr "hx-vals" values
/// The name of the message to swap into the DOM. /// <summary>The URL of the SSE server</summary>
let _sseSwap = attr "sse-swap" /// <param name="url">The URL from which events will be received</param>
/// <returns>A configured <c>sse-connect</c> attribute</returns>
/// <seealso href="https://htmx.org/extensions/sse/#usage">Extension Docs</seealso>
let _sseConnect url =
attr "sse-connect" url
/// The URL of the SSE server. /// <summary>The name(s) of the message(s) to swap into the DOM</summary>
let _sseConnect = attr "sse-connect" /// <param name="messages">The message names (comma-delimited) to swap (use "message" for unnamed events)</param>
/// <returns>A configured <c>sse-swap</c> attribute</returns>
/// <seealso href="https://htmx.org/extensions/sse/#usage">Extension Docs</seealso>
let _sseSwap messages =
attr "sse-swap" messages
/// <summary>Script tags to pull htmx into a web page</summary> /// <summary>Script tags to pull htmx into a web page</summary>
@ -552,9 +697,9 @@ module RenderFragment =
$"<em>&ndash; ID {nodeId} not found &ndash;</em>" $"<em>&ndash; ID {nodeId} not found &ndash;</em>"
/// <summary>Find the node with the named ID</summary> /// <summary>Find the node with the named ID</summary>
/// <param name="nodeId">The <tt>id</tt> attribute to find</param> /// <param name="nodeId">The <c>id</c> attribute to find</param>
/// <param name="node">The node tree to search</param> /// <param name="node">The node tree to search</param>
/// <returns>The node with the requested <tt>id</tt> attribute, or <tt>None</tt> if it was not found</returns> /// <returns>The node with the requested <c>id</c> attribute, or <c>None</c> if it was not found</returns>
let rec findIdNode nodeId (node: XmlNode) : XmlNode option = let rec findIdNode nodeId (node: XmlNode) : XmlNode option =
match node with match node with
| Text _ -> None | Text _ -> None
@ -567,18 +712,18 @@ module RenderFragment =
module AsString = module AsString =
/// <summary>Render to HTML for the given ID</summary> /// <summary>Render to HTML for the given ID</summary>
/// <param name="nodeId">The <tt>id</tt> attribute for the node to be rendered</param> /// <param name="nodeId">The <c>id</c> attribute for the node to be rendered</param>
/// <param name="nodes">The node trees to search</param> /// <param name="nodes">The node trees to search</param>
/// <returns>The HTML for the given <tt>id</tt> node, or an error message if it was not found</returns> /// <returns>The HTML for the given <c>id</c> node, or an error message if it was not found</returns>
let htmlFromNodes nodeId (nodes: XmlNode list) = let htmlFromNodes nodeId (nodes: XmlNode list) =
match nodes |> List.tryPick (findIdNode nodeId) with match nodes |> List.tryPick (findIdNode nodeId) with
| Some idNode -> RenderView.AsString.htmlNode idNode | Some idNode -> RenderView.AsString.htmlNode idNode
| None -> nodeNotFound nodeId | None -> nodeNotFound nodeId
/// <summary>Render to HTML for the given ID</summary> /// <summary>Render to HTML for the given ID</summary>
/// <param name="nodeId">The <tt>id</tt> attribute for the node to be rendered</param> /// <param name="nodeId">The <c>id</c> attribute for the node to be rendered</param>
/// <param name="node">The node tree to search</param> /// <param name="node">The node tree to search</param>
/// <returns>The HTML for the given <tt>id</tt> node, or an error message if it was not found</returns> /// <returns>The HTML for the given <c>id</c> node, or an error message if it was not found</returns>
let htmlFromNode nodeId node = let htmlFromNode nodeId node =
match findIdNode nodeId node with match findIdNode nodeId node with
| Some idNode -> RenderView.AsString.htmlNode idNode | Some idNode -> RenderView.AsString.htmlNode idNode
@ -591,18 +736,18 @@ module RenderFragment =
let private utf8 = System.Text.Encoding.UTF8 let private utf8 = System.Text.Encoding.UTF8
/// <summary>Render to bytes for the given ID</summary> /// <summary>Render to bytes for the given ID</summary>
/// <param name="nodeId">The <tt>id</tt> attribute for the node to be rendered</param> /// <param name="nodeId">The <c>id</c> attribute for the node to be rendered</param>
/// <param name="nodes">The node trees to search</param> /// <param name="nodes">The node trees to search</param>
/// <returns>The bytes for the given <tt>id</tt> node, or an error message if it was not found</returns> /// <returns>The bytes for the given <c>id</c> node, or an error message if it was not found</returns>
let htmlFromNodes nodeId (nodes: XmlNode list) = let htmlFromNodes nodeId (nodes: XmlNode list) =
match nodes |> List.tryPick (findIdNode nodeId) with match nodes |> List.tryPick (findIdNode nodeId) with
| Some idNode -> RenderView.AsBytes.htmlNode idNode | Some idNode -> RenderView.AsBytes.htmlNode idNode
| None -> nodeNotFound nodeId |> utf8.GetBytes | None -> nodeNotFound nodeId |> utf8.GetBytes
/// <summary>Render to bytes for the given ID</summary> /// <summary>Render to bytes for the given ID</summary>
/// <param name="nodeId">The <tt>id</tt> attribute for the node to be rendered</param> /// <param name="nodeId">The <c>id</c> attribute for the node to be rendered</param>
/// <param name="node">The node tree to search</param> /// <param name="node">The node tree to search</param>
/// <returns>The bytes for the given <tt>id</tt> node, or an error message if it was not found</returns> /// <returns>The bytes for the given <c>id</c> node, or an error message if it was not found</returns>
let htmlFromNode nodeId node = let htmlFromNode nodeId node =
match findIdNode nodeId node with match findIdNode nodeId node with
| Some idNode -> RenderView.AsBytes.htmlNode idNode | Some idNode -> RenderView.AsBytes.htmlNode idNode
@ -612,18 +757,18 @@ module RenderFragment =
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module IntoStringBuilder = module IntoStringBuilder =
/// <summary>Render HTML into a <tt>StringBuilder</tt> for the given ID</summary> /// <summary>Render HTML into a <c>StringBuilder</c> for the given ID</summary>
/// <param name="sb">The <tt>StringBuilder</tt> into which the bytes will be rendered</param> /// <param name="sb">The <c>StringBuilder</c> into which the bytes will be rendered</param>
/// <param name="nodeId">The <tt>id</tt> attribute for the node to be rendered</param> /// <param name="nodeId">The <c>id</c> attribute for the node to be rendered</param>
/// <param name="nodes">The node trees to search</param> /// <param name="nodes">The node trees to search</param>
let htmlFromNodes sb nodeId (nodes: XmlNode list) = let htmlFromNodes sb nodeId (nodes: XmlNode list) =
match nodes |> List.tryPick (findIdNode nodeId) with match nodes |> List.tryPick (findIdNode nodeId) with
| Some idNode -> RenderView.IntoStringBuilder.htmlNode sb idNode | Some idNode -> RenderView.IntoStringBuilder.htmlNode sb idNode
| None -> nodeNotFound nodeId |> sb.Append |> ignore | None -> nodeNotFound nodeId |> sb.Append |> ignore
/// <summary>Render HTML into a <tt>StringBuilder</tt> for the given ID</summary> /// <summary>Render HTML into a <c>StringBuilder</c> for the given ID</summary>
/// <param name="sb">The <tt>StringBuilder</tt> into which the bytes will be rendered</param> /// <param name="sb">The <c>StringBuilder</c> into which the bytes will be rendered</param>
/// <param name="nodeId">The <tt>id</tt> attribute for the node to be rendered</param> /// <param name="nodeId">The <c>id</c> attribute for the node to be rendered</param>
/// <param name="node">The node tree to search</param> /// <param name="node">The node tree to search</param>
let htmlFromNode sb nodeId node = let htmlFromNode sb nodeId node =
match findIdNode nodeId node with match findIdNode nodeId node with