Compare commits

...

5 Commits

Author SHA1 Message Date
6677892859 Complete doc work; add HxSync module 2025-01-24 16:47:57 -05:00
cede486099 WIP on docs 2025-01-23 20:17:51 -05:00
7b5912e5e2 WIP on docs 2025-01-03 19:31:58 -05:00
5e28714215 WIP on docs
- bump version
2024-12-30 22:06:27 -05:00
28cec1cb70 Drop .NET 6 support (#14) 2024-12-30 22:05:52 -05:00
9 changed files with 904 additions and 425 deletions

View File

@ -1,28 +1,53 @@
/// Common definitions shared between attribute values and response headers /// <summary>Common definitions shared between attribute values and response headers</summary>
[<AutoOpen>] [<AutoOpen>]
module Giraffe.Htmx.Common module Giraffe.Htmx.Common
/// Valid values for the `hx-swap` attribute / `HX-Reswap` header (may be combined with swap/settle/scroll/show config) /// <summary>Serialize a list of key/value pairs to JSON (very rudimentary)</summary>
/// <param name="pairs">The key/value pairs to be serialized to JSON</param>
/// <returns>A string with the key/value pairs serialized to JSON</returns>
let internal toJson (pairs: (string * string) list) =
pairs
|> List.map (fun pair -> sprintf "\"%s\": \"%s\"" (fst pair) ((snd pair).Replace ("\"", "\\\"")))
|> String.concat ", "
|> sprintf "{ %s }"
/// <summary>Convert a boolean to lowercase "true" or "false"</summary>
/// <param name="boolValue">The boolean value to convert</param>
/// <returns>"true" for <c>true</c>, "false" for <c>false</c></returns>
let internal toLowerBool (boolValue: bool) =
(string boolValue).ToLowerInvariant()
/// <summary>Valid values for the <c>hx-swap</c> attribute / <c>HX-Reswap</c> header</summary>
/// <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 =
/// The default, replace the inner html of the target element /// <summary>The default, replace the inner HTML of the target element</summary>
[<Literal>]
let InnerHtml = "innerHTML" let InnerHtml = "innerHTML"
/// Replace the entire target element with the response /// <summary>Replace the entire target element with the response</summary>
[<Literal>]
let OuterHtml = "outerHTML" let OuterHtml = "outerHTML"
/// Insert the response before the target element /// <summary>Insert the response before the target element</summary>
[<Literal>]
let BeforeBegin = "beforebegin" let BeforeBegin = "beforebegin"
/// Insert the response before the first child of the target element /// <summary>Insert the response before the first child of the target element</summary>
[<Literal>]
let AfterBegin = "afterbegin" let AfterBegin = "afterbegin"
/// Insert the response after the last child of the target element /// <summary>Insert the response after the last child of the target element</summary>
[<Literal>]
let BeforeEnd = "beforeend" let BeforeEnd = "beforeend"
/// Insert the response after the target element /// <summary>Insert the response after the target element</summary>
[<Literal>]
let AfterEnd = "afterend" let AfterEnd = "afterend"
/// Does not append content from response (out of band items will still be processed). /// <summary>Does not append content from response (out of band items will still be processed).</summary>
[<Literal>]
let None = "none" let None = "none"

View File

@ -4,6 +4,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>Common definitions for Giraffe.Htmx</Description> <Description>Common definitions for Giraffe.Htmx</Description>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -16,4 +17,8 @@
<PackageReference Update="FSharp.Core" Version="6.0.0" /> <PackageReference Update="FSharp.Core" Version="6.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Giraffe.Htmx" />
<InternalsVisibleTo Include="Giraffe.ViewEngine.Htmx" />
</ItemGroup>
</Project> </Project>

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks> <TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<VersionPrefix>2.0.4</VersionPrefix> <VersionPrefix>2.0.5</VersionPrefix>
<PackageReleaseNotes>Update script tags to pull htmx 2.0.4 (no header or attribute changes)</PackageReleaseNotes> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>Add full packaged XML documentation; update script tags to pull htmx 2.0.5 (no header or attribute changes)</PackageReleaseNotes>
<Authors>danieljsummers</Authors> <Authors>danieljsummers</Authors>
<Company>Bit Badger Solutions</Company> <Company>Bit Badger Solutions</Company>
<PackageProjectUrl>https://git.bitbadger.solutions/bit-badger/Giraffe.Htmx</PackageProjectUrl> <PackageProjectUrl>https://git.bitbadger.solutions/bit-badger/Giraffe.Htmx</PackageProjectUrl>

View File

@ -4,6 +4,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>htmx header extensions and helpers for Giraffe</Description> <Description>htmx header extensions and helpers for Giraffe</Description>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -11,121 +11,162 @@ let private hdr (headers : IHeaderDictionary) hdr =
/// Extensions to the header dictionary /// Extensions to the header dictionary
type IHeaderDictionary with type IHeaderDictionary with
/// Indicates that the request is via an element using `hx-boost` /// <summary>Indicates that the request is via an element using <c>hx-boost</c></summary>
member this.HxBoosted with get () = hdr this "HX-Boosted" |> Option.map bool.Parse member this.HxBoosted
with get () = hdr this "HX-Boosted" |> Option.map bool.Parse
/// The current URL of the browser _(note that this does not update until after settle)_ /// <summary>The current URL of the browser <em>(note that this does not update until after settle)</em></summary>
member this.HxCurrentUrl with get () = hdr this "HX-Current-URL" |> Option.map Uri member this.HxCurrentUrl
with get () = hdr this "HX-Current-URL" |> Option.map Uri
/// `true` if the request is for history restoration after a miss in the local history cache /// <summary><c>true</c> if the request is for history restoration after a miss in the local history cache</summary>
member this.HxHistoryRestoreRequest with get () = hdr this "HX-History-Restore-Request" |> Option.map bool.Parse member this.HxHistoryRestoreRequest
with get () = hdr this "HX-History-Restore-Request" |> Option.map bool.Parse
/// The user response to an `hx-prompt` /// <summary>The user response to an <c>hx-prompt</c></summary>
member this.HxPrompt with get () = hdr this "HX-Prompt" member this.HxPrompt
with get () = hdr this "HX-Prompt"
/// `true` if the request came from HTMX /// <summary><c>true</c> if the request came from htmx</summary>
member this.HxRequest with get () = hdr this "HX-Request" |> Option.map bool.Parse member this.HxRequest
with get () = hdr this "HX-Request" |> Option.map bool.Parse
/// The `id` of the target element if it exists /// <summary>The <c>id</c> attribute of the target element if it exists</summary>
member this.HxTarget with get () = hdr this "HX-Target" member this.HxTarget
with get () = hdr this "HX-Target"
/// The `id` of the triggered element if it exists /// <summary>The <c>id</c> attribute of the triggered element if it exists</summary>
member this.HxTrigger with get () = hdr this "HX-Trigger" member this.HxTrigger
with get () = hdr this "HX-Trigger"
/// The `name` of the triggered element if it exists /// <summary>The <c>name</c> attribute of the triggered element if it exists</summary>
member this.HxTriggerName with get () = hdr this "HX-Trigger-Name" member this.HxTriggerName
with get () = hdr this "HX-Trigger-Name"
/// Extensions for the request object /// Extensions for the request object
type HttpRequest with type HttpRequest with
/// Whether this request was initiated from htmx /// <summary>Whether this request was initiated from htmx</summary>
member this.IsHtmx with get () = this.Headers.HxRequest |> Option.defaultValue false member this.IsHtmx
with get () = this.Headers.HxRequest |> Option.defaultValue false
/// Whether this request is an htmx history-miss refresh request /// <summary>Whether this request is an htmx history-miss refresh request</summary>
member this.IsHtmxRefresh with get () = member this.IsHtmxRefresh
this.IsHtmx && (this.Headers.HxHistoryRestoreRequest |> Option.defaultValue false) with get () = this.IsHtmx && (this.Headers.HxHistoryRestoreRequest |> Option.defaultValue false)
/// HTTP handlers for setting output headers /// <summary>HTTP handlers for setting output headers</summary>
[<AutoOpen>] [<AutoOpen>]
module Handlers = module Handlers =
/// Convert a boolean to lowercase `true` or `false` open Giraffe.Htmx.Common
let private toLowerBool (trueOrFalse : bool) =
(string trueOrFalse).ToLowerInvariant ()
/// Serialize a list of key/value pairs to JSON (very rudimentary) /// <summary>Instruct htmx to perform a client-side redirect for content</summary>
let private toJson (evts : (string * string) list) = /// <param name="path">The path where the content should be found</param>
evts /// <returns>An HTTP handler with the <c>HX-Location</c> header set</returns>
|> List.map (fun evt -> sprintf "\"%s\": \"%s\"" (fst evt) ((snd evt).Replace ("\"", "\\\""))) /// <seealso href="https://htmx.org/headers/hx-location/">Documentation</seealso>
|> String.concat ", " let withHxLocation (path: string) : HttpHandler =
|> sprintf "{ %s }" setHttpHeader "HX-Location" path
/// Pushes a new url into the history stack /// <summary>Pushes a new url into the history stack</summary>
let withHxPushUrl : string -> HttpHandler = /// <param name="url">The URL to be pushed</param>
setHttpHeader "HX-Push-Url" /// <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 =
setHttpHeader "HX-Push-Url" url
/// Explicitly do not push a new URL into the history stack /// <summary>Explicitly do not push a new URL into the history stack</summary>
/// <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 /// <summary>Can be used to do a client-side redirect to a new location</summary>
[<Obsolete "Use withHxPushUrl; HX-Push was replaced by HX-Push-Url in v1.8.0">] /// <param name="url">The URL to which the client should be redirected</param>
let withHxPush = withHxPushUrl /// <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 =
setHttpHeader "HX-Redirect" url
/// Explicitly do not push a new URL into the history stack /// <summary>If set to <c>true</c> the client side will do a full refresh of the page</summary>
[<Obsolete "Use withHxNoPushUrl; HX-Push was replaced by HX-Push-Url in v1.8.0">] /// <param name="shouldRefresh">Whether the client should refresh their page</param>
let withHxNoPush = withHxNoPushUrl /// <returns>An HTTP handler with the <c>HX-Refresh</c> header set</returns>
let withHxRefresh shouldRefresh : HttpHandler =
(toLowerBool >> setHttpHeader "HX-Refresh") shouldRefresh
/// Can be used to do a client-side redirect to a new location /// <summary>Replaces the current URL in the history stack</summary>
let withHxRedirect : string -> HttpHandler = /// <param name="url">The URL to place in the history stack in place of the current one</param>
setHttpHeader "HX-Redirect" /// <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 =
setHttpHeader "HX-Replace-Url" url
/// If set to `true` the client side will do a a full refresh of the page /// <summary>Explicitly do not replace the current URL in the history stack</summary>
let withHxRefresh : bool -> HttpHandler = /// <returns>An HTTP handler with the <c>HX-Replace-URL</c> header set to <c>false</c></returns>
toLowerBool >> setHttpHeader "HX-Refresh" /// <seealso href="https://htmx.org/headers/hx-replace-url/">Documentation</seealso>
/// Replaces the current URL in the history stack
let withHxReplaceUrl : string -> HttpHandler =
setHttpHeader "HX-Replace-Url"
/// Explicitly do not replace the current URL in the history stack
let withHxNoReplaceUrl : HttpHandler = let withHxNoReplaceUrl : HttpHandler =
toLowerBool false |> withHxReplaceUrl toLowerBool false |> withHxReplaceUrl
/// Override which portion of the response will be swapped into the target document /// <summary>Override which portion of the response will be swapped into the target document</summary>
let withHxReselect : string -> HttpHandler = /// <param name="target">The selector for the new response target</param>
setHttpHeader "HX-Reselect" /// <returns>An HTTP handler with the <c>HX-Reselect</c> header set</returns>
let withHxReselect (target: string) : HttpHandler =
setHttpHeader "HX-Reselect" target
/// Override the `hx-swap` attribute from the initiating element /// <summary>Override the <c>hx-swap</c> attribute from the initiating element</summary>
let withHxReswap : string -> HttpHandler = /// <param name="swap">The swap value to override</param>
setHttpHeader "HX-Reswap" /// <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>
let withHxReswap (swap: string) : HttpHandler =
setHttpHeader "HX-Reswap" swap
/// Allows you to override the `hx-target` attribute /// <summary>Allows you to override the <c>hx-target</c> attribute</summary>
let withHxRetarget : string -> HttpHandler = /// <param name="target">The new target for the response</param>
setHttpHeader "HX-Retarget" /// <returns>An HTTP handler with the <c>HX-Retarget</c> header set</returns>
let withHxRetarget (target: string) : HttpHandler =
setHttpHeader "HX-Retarget" target
/// Allows you to trigger a single client side event /// <summary>Allows you to trigger a single client side event</summary>
let withHxTrigger : string -> HttpHandler = /// <param name="evt">The call to the event that should be triggered</param>
setHttpHeader "HX-Trigger" /// <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 =
setHttpHeader "HX-Trigger" evt
/// Allows you to trigger multiple client side events /// <summary>Allows you to trigger multiple client side events</summary>
/// <param name="evts">The calls to events that should be triggered</param>
/// <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"
/// Allows you to trigger a single client side event after changes have settled /// <summary>Allows you to trigger a single client side event after changes have settled</summary>
let withHxTriggerAfterSettle : string -> HttpHandler = /// <param name="evt">The call to the event that should be triggered</param>
setHttpHeader "HX-Trigger-After-Settle" /// <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 =
setHttpHeader "HX-Trigger-After-Settle" evt
/// Allows you to trigger multiple client side events after changes have settled /// <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>
/// <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"
/// Allows you to trigger a single client side event after DOM swapping occurs /// <summary>Allows you to trigger a single client side event after DOM swapping occurs</summary>
let withHxTriggerAfterSwap : string -> HttpHandler = /// <param name="evt">The call to the event that should be triggered</param>
setHttpHeader "HX-Trigger-After-Swap" /// <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 =
setHttpHeader "HX-Trigger-After-Swap" evt
/// Allows you to trigger multiple client side events after DOM swapping occurs /// <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>
/// <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" [
@ -497,6 +497,32 @@ let hxRequest =
] ]
] ]
/// Tests for the HxSync module
let hxSync =
testList "HxSync" [
test "Drop is correct" {
Expect.equal HxSync.Drop "drop" "Drop is incorrect"
}
test "Abort is correct" {
Expect.equal HxSync.Abort "abort" "Abort is incorrect"
}
test "Replace is correct" {
Expect.equal HxSync.Replace "replace" "Replace is incorrect"
}
test "Queue is correct" {
Expect.equal HxSync.Queue "queue" "Queue is incorrect"
}
test "QueueFirst is correct" {
Expect.equal HxSync.QueueFirst "queue first" "QueueFirst is incorrect"
}
test "QueueLast is correct" {
Expect.equal HxSync.QueueLast "queue last" "QueueLast is incorrect"
}
test "QueueAll is correct" {
Expect.equal HxSync.QueueAll "queue all" "QueueAll is incorrect"
}
]
/// Tests for the HxTrigger module /// Tests for the HxTrigger module
let hxTrigger = let hxTrigger =
testList "HxTrigger" [ testList "HxTrigger" [
@ -636,6 +662,9 @@ let hxTrigger =
test "succeeds when it is not the first modifier" { test "succeeds when it is not the first modifier" {
Expect.equal (HxTrigger.Queue "def" "click") "click queue:def" "Queue modifier incorrect" Expect.equal (HxTrigger.Queue "def" "click") "click queue:def" "Queue modifier incorrect"
} }
test "succeeds when no type of queueing is given" {
Expect.equal (HxTrigger.Queue "" "blur") "blur queue" "Queue modifier incorrect"
}
] ]
testList "QueueFirst" [ testList "QueueFirst" [
test "succeeds when it is the first modifier" { test "succeeds when it is the first modifier" {
@ -726,7 +755,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>"""
@ -757,7 +786,7 @@ let attributes =
hr [ _hxPost "/hear-ye-hear-ye" ] |> shouldRender """<hr hx-post="/hear-ye-hear-ye">""" hr [ _hxPost "/hear-ye-hear-ye" ] |> shouldRender """<hr hx-post="/hear-ye-hear-ye">"""
} }
test "_hxPreserve succeeds" { test "_hxPreserve succeeds" {
img [ _hxPreserve ] |> shouldRender """<img hx-preserve="true">""" img [ _hxPreserve ] |> shouldRender """<img hx-preserve>"""
} }
test "_hxPrompt succeeds" { test "_hxPrompt succeeds" {
strong [ _hxPrompt "Who goes there?" ] [] strong [ _hxPrompt "Who goes there?" ] []
@ -792,7 +821,8 @@ let attributes =
li [ _hxSwapOob "true" ] [] |> shouldRender """<li hx-swap-oob="true"></li>""" li [ _hxSwapOob "true" ] [] |> shouldRender """<li hx-swap-oob="true"></li>"""
} }
test "_hxSync succeeds" { test "_hxSync succeeds" {
nav [ _hxSync "closest form:abort" ] [] |> shouldRender """<nav hx-sync="closest form:abort"></nav>""" nav [ _hxSync "closest form" HxSync.Abort ] []
|> shouldRender """<nav hx-sync="closest form:abort"></nav>"""
} }
test "_hxTarget succeeds" { test "_hxTarget succeeds" {
header [ _hxTarget "#somewhereElse" ] [] |> shouldRender """<header hx-target="#somewhereElse"></header>""" header [ _hxTarget "#somewhereElse" ] [] |> shouldRender """<header hx-target="#somewhereElse"></header>"""
@ -986,6 +1016,7 @@ let allTests =
hxHeaders hxHeaders
hxParams hxParams
hxRequest hxRequest
hxSync
hxTrigger hxTrigger
hxVals hxVals
attributes attributes

View File

@ -4,6 +4,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>Extensions to Giraffe View Engine to support htmx attributes and their values</Description> <Description>Extensions to Giraffe View Engine to support htmx attributes and their values</Description>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff