From 32e962416d04f50cb08c7f2d13729e83c5c456aa Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Thu, 23 May 2024 19:19:07 -0400 Subject: [PATCH 1/2] Migrate PR 10 from GitHub https://github.com/bit-badger/Giraffe.Htmx/pull/10 --- src/Tests/ViewEngine.fs | 6 ++++++ src/ViewEngine.Htmx/Htmx.fs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/Tests/ViewEngine.fs b/src/Tests/ViewEngine.fs index a7f9146..2ca87c6 100644 --- a/src/Tests/ViewEngine.fs +++ b/src/Tests/ViewEngine.fs @@ -811,6 +811,12 @@ let attributes = test "_hxWs succeeds" { ul [ _hxWs "connect:/web-socket" ] [] |> shouldRender """""" } + test "_sseSwap succeeds" { + ul [ _sseSwap "sseMessageName" ] [] |> shouldRender """""" + } + test "_sseConnect succeeds" { + div [ _sseConnect "/gps/sse" ] [] |> shouldRender """
""" + } ] /// Tests for the Script module diff --git a/src/ViewEngine.Htmx/Htmx.fs b/src/ViewEngine.Htmx/Htmx.fs index 1d8f34a..97ede77 100644 --- a/src/ViewEngine.Htmx/Htmx.fs +++ b/src/ViewEngine.Htmx/Htmx.fs @@ -317,6 +317,7 @@ module HxVals = /// Create values from a list of key/value pairs let From = toJson + /// Attributes and flags for htmx [] module HtmxAttrs = @@ -438,6 +439,12 @@ module HtmxAttrs = /// Establishes a WebSocket or sends information to one let _hxWs = attr "hx-ws" + /// The name of the message to swap into the DOM. + let _sseSwap = attr "sse-swap" + + /// The URL of the SSE server. + let _sseConnect = attr "sse-connect" + /// Script tags to pull htmx into an web page module Script = From 1a11e3511a42c266b564beacfabaa91cc37eaa09 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Thu, 23 May 2024 19:26:00 -0400 Subject: [PATCH 2/2] Update htmx to v2.0.0-beta4 --- src/Common/README.md | 2 +- src/Directory.Build.props | 4 ++-- src/Htmx/README.md | 2 +- src/Tests/ViewEngine.fs | 4 ++-- src/ViewEngine.Htmx/Htmx.fs | 8 ++++---- src/ViewEngine.Htmx/README.md | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Common/README.md b/src/Common/README.md index a3d5abe..12a8554 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: 2.0.0-beta3** +**htmx version: 2.0.0-beta4** diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ebd3cee..750e0f4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,8 +3,8 @@ net6.0;net7.0;net8.0 2.0.0 - beta3 - Update script tags to pull htmx 2.0.0-beta3 + beta4 + Update script tags to pull htmx 2.0.0-beta4; add SSE attributes danieljsummers Bit Badger Solutions https://git.bitbadger.solutions/bit-badger/Giraffe.Htmx diff --git a/src/Htmx/README.md b/src/Htmx/README.md index d45c250..1a5d066 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: 2.0.0-beta3** +**htmx version: 2.0.0-beta4** _Note that htmx 2.0 is a BETA release. The [migration guide](https://v2-0v2-0.htmx.org/migration-guide-htmx-1/) does not currently specify any request or response header changes. This means that, as of this release, there are no required code changes in moving to this major version._ diff --git a/src/Tests/ViewEngine.fs b/src/Tests/ViewEngine.fs index 2ca87c6..cfacdc1 100644 --- a/src/Tests/ViewEngine.fs +++ b/src/Tests/ViewEngine.fs @@ -826,14 +826,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 97ede77..e76b6cf 100644 --- a/src/ViewEngine.Htmx/Htmx.fs +++ b/src/ViewEngine.Htmx/Htmx.fs @@ -451,14 +451,14 @@ module Script = /// Script tag to load the minified version from unpkg.com let minified = - script [ _src "https://unpkg.com/htmx.org@2.0.0-beta3" - _integrity "sha384-9wQIC/7bdsqgMwBWWcREHyQOU7vU6P9J2tgQq0056HPV9t35Ypm4vPYA6Ud1MgY9" + script [ _src "https://unpkg.com/htmx.org@2.0.0-beta4" + _integrity "sha384-QprZjU1JKuXu/TnlURCTYppToUjigoOZCrzQtRXAjHttxoV9gkqiizVeAwjeGy1f" _crossorigin "anonymous" ] [] /// Script tag to load the unminified version from unpkg.com let unminified = - script [ _src "https://unpkg.com/htmx.org@2.0.0-beta3/dist/htmx.js" - _integrity "sha384-lGcccsClz1aGJ47pTvGg8H69LcUEacfYDRwjlmFmRi35GGy8sBegHZaca5O4/Kai" + script [ _src "https://unpkg.com/htmx.org@2.0.0-beta4/dist/htmx.js" + _integrity "sha384-n/53Us+nZur0snldc6yl7W3paw5/sbtpXhImQJk9JZf0KQjzCP6lbBWmAtFsCSb9" _crossorigin "anonymous" ] [] diff --git a/src/ViewEngine.Htmx/README.md b/src/ViewEngine.Htmx/README.md index bdf6de9..b66467e 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: 2.0.0-beta3** +**htmx version: 2.0.0-beta4** _Note that this is a BETA release of htmx 2.0; see [the migration guide](https://v2-0v2-0.htmx.org/migration-guide-htmx-1/) for changes_