Migrate PR 10 from GitHub

https://github.com/bit-badger/Giraffe.Htmx/pull/10
This commit is contained in:
Daniel J. Summers 2024-05-23 19:19:07 -04:00
parent 29839fa795
commit 32e962416d
2 changed files with 13 additions and 0 deletions

View File

@ -811,6 +811,12 @@ let attributes =
test "_hxWs succeeds" { test "_hxWs succeeds" {
ul [ _hxWs "connect:/web-socket" ] [] |> shouldRender """<ul hx-ws="connect:/web-socket"></ul>""" ul [ _hxWs "connect:/web-socket" ] [] |> shouldRender """<ul hx-ws="connect:/web-socket"></ul>"""
} }
test "_sseSwap succeeds" {
ul [ _sseSwap "sseMessageName" ] [] |> shouldRender """<ul sse-swap="sseMessageName"></ul>"""
}
test "_sseConnect succeeds" {
div [ _sseConnect "/gps/sse" ] [] |> shouldRender """<div sse-connect="/gps/sse"></div>"""
}
] ]
/// Tests for the Script module /// Tests for the Script module

View File

@ -317,6 +317,7 @@ module HxVals =
/// Create values from a list of key/value pairs /// Create values from a list of key/value pairs
let From = toJson let From = toJson
/// Attributes and flags for htmx /// Attributes and flags for htmx
[<AutoOpen>] [<AutoOpen>]
module HtmxAttrs = module HtmxAttrs =
@ -438,6 +439,12 @@ module HtmxAttrs =
/// Establishes a WebSocket or sends information to one /// Establishes a WebSocket or sends information to one
let _hxWs = attr "hx-ws" 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 /// Script tags to pull htmx into an web page
module Script = module Script =