diff --git a/src/Common/README.md b/src/Common/README.md index 6c34ba1..1d17a81 100644 --- a/src/Common/README.md +++ b/src/Common/README.md @@ -2,4 +2,4 @@ This package contains common code shared between [`Giraffe.Htmx`](https://www.nuget.org/packages/Giraffe.Htmx) and [`Giraffe.ViewEngine.Htmx`](https://www.nuget.org/packages/Giraffe.ViewEngine.Htmx), and will be automatically installed when you install either one. -**htmx version: 1.9.2** +**htmx version: 1.9.3** diff --git a/src/Directory.Build.props b/src/Directory.Build.props index cef8e6b..09def07 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,8 +2,8 @@ net6.0;net7.0 - 1.9.2 - Update script tags to pull htmx 1.9.2 + 1.9.3 + Add HX-Reselect response header; update script tags to pull htmx 1.9.3 danieljsummers Bit Badger Solutions https://github.com/bit-badger/Giraffe.Htmx diff --git a/src/Htmx/Htmx.fs b/src/Htmx/Htmx.fs index edfb8db..b21559a 100644 --- a/src/Htmx/Htmx.fs +++ b/src/Htmx/Htmx.fs @@ -94,6 +94,10 @@ module Handlers = let withHxNoReplaceUrl : HttpHandler = toLowerBool false |> withHxReplaceUrl + /// Override which portion of the response will be swapped into the target document + let withHxReselect : string -> HttpHandler = + setHttpHeader "HX-Reselect" + /// Override the `hx-swap` attribute from the initiating element let withHxReswap : string -> HttpHandler = setHttpHeader "HX-Reswap" diff --git a/src/Htmx/README.md b/src/Htmx/README.md index 189a10d..4488bfc 100644 --- a/src/Htmx/README.md +++ b/src/Htmx/README.md @@ -2,7 +2,7 @@ This package enables server-side support for [htmx](https://htmx.org) within [Giraffe](https://giraffe.wiki) and ASP.NET's `HttpContext`. -**htmx version: 1.9.2** +**htmx version: 1.9.3** ### Setup diff --git a/src/Tests/Htmx.fs b/src/Tests/Htmx.fs index 338e488..5b1d162 100644 --- a/src/Tests/Htmx.fs +++ b/src/Tests/Htmx.fs @@ -265,6 +265,14 @@ let handlers = Expect.isTrue (dic.ContainsKey "HX-Replace-Url") "The HX-Replace-Url header should be present" Expect.equal dic["HX-Replace-Url"].[0] "false" "The HX-Replace-Url value was incorrect" } + testTask "withHxReselect succeeds" { + let ctx = Substitute.For () + let dic = HeaderDictionary () + ctx.Response.Headers.ReturnsForAnyArgs dic |> ignore + let! _ = withHxReselect "#test" next ctx + Expect.isTrue (dic.ContainsKey "HX-Reselect") "The HX-Reselect header should be present" + Expect.equal dic["HX-Reselect"].[0] "#test" "The HX-Reselect value was incorrect" + } testTask "withHxReswap succeeds" { let ctx = Substitute.For () let dic = HeaderDictionary () diff --git a/src/Tests/ViewEngine.fs b/src/Tests/ViewEngine.fs index 74a9596..ef6a273 100644 --- a/src/Tests/ViewEngine.fs +++ b/src/Tests/ViewEngine.fs @@ -422,14 +422,14 @@ let script = let html = RenderView.AsString.htmlNode Script.minified Expect.equal html - """""" + """""" "Minified script tag is incorrect" } test "unminified succeeds" { let html = RenderView.AsString.htmlNode Script.unminified Expect.equal html - """""" + """""" "Unminified script tag is incorrect" } ] diff --git a/src/ViewEngine.Htmx/Htmx.fs b/src/ViewEngine.Htmx/Htmx.fs index 1251f98..084a91e 100644 --- a/src/ViewEngine.Htmx/Htmx.fs +++ b/src/ViewEngine.Htmx/Htmx.fs @@ -296,14 +296,14 @@ module Script = /// Script tag to load the minified version from unpkg.com let minified = - script [ _src "https://unpkg.com/htmx.org@1.9.2" - _integrity "sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h" + script [ _src "https://unpkg.com/htmx.org@1.9.3" + _integrity "sha384-lVb3Rd/Ca0AxaoZg5sACe8FJKF0tnUgR2Kd7ehUOG5GCcROv5uBIZsOqovBAcWua" _crossorigin "anonymous" ] [] /// Script tag to load the unminified version from unpkg.com let unminified = - script [ _src "https://unpkg.com/htmx.org@1.9.2/dist/htmx.js" - _integrity "sha384-8ADa8Z9mz9MtKHmL1vCmqgEM5Q7eIiradzjEpmeELJ4kex3ibvmnctBNHlpLr/Zl" + script [ _src "https://unpkg.com/htmx.org@1.9.3/dist/htmx.js" + _integrity "sha384-6nBlGdeSOmH5YDWlJKzskaf7hqWLq8viLPbWeCLsFJXVw7IdNw8GXQnpQ8FwbV8k" _crossorigin "anonymous" ] [] diff --git a/src/ViewEngine.Htmx/README.md b/src/ViewEngine.Htmx/README.md index 10875bf..6b3ad1e 100644 --- a/src/ViewEngine.Htmx/README.md +++ b/src/ViewEngine.Htmx/README.md @@ -2,7 +2,7 @@ This package enables [htmx](https://htmx.org) support within the [Giraffe](https://giraffe.wiki) view engine. -**htmx version: 1.9.2** +**htmx version: 1.9.3** ### Setup