v4, alpha 6 (#17)
Reviewed-on: #17
This commit was merged in pull request #17.
This commit is contained in:
@@ -24,6 +24,7 @@ type IHeaderDictionary with
|
||||
with get () = hdr this "HX-History-Restore-Request" |> Option.map bool.Parse
|
||||
|
||||
/// <summary>The user response to an <c>hx-prompt</c></summary>
|
||||
[<Obsolete "hx-prompt is removed in v4">]
|
||||
member this.HxPrompt
|
||||
with get () = hdr this "HX-Prompt"
|
||||
|
||||
@@ -31,15 +32,29 @@ type IHeaderDictionary with
|
||||
member this.HxRequest
|
||||
with get () = hdr this "HX-Request" |> Option.map bool.Parse
|
||||
|
||||
/// <summary>The tag name (fst) and <c>id</c> attribute (snd) of the element triggering this request</summary>
|
||||
member this.HxSource
|
||||
with get () =
|
||||
match hdr this "HX-Source" with
|
||||
| Some src ->
|
||||
let parts = src.Split "#"
|
||||
if parts.Length = 1 then
|
||||
Some (parts[0], None)
|
||||
else
|
||||
Some (parts[0], if parts[1] <> "" then Some parts[1] else None)
|
||||
| None -> None
|
||||
|
||||
/// <summary>The <c>id</c> attribute of the target element if it exists</summary>
|
||||
member this.HxTarget
|
||||
with get () = hdr this "HX-Target"
|
||||
|
||||
/// <summary>The <c>id</c> attribute of the triggered element if it exists</summary>
|
||||
[<Obsolete "HX-Trigger is removed in v4; use the second item of HX-Source">]
|
||||
member this.HxTrigger
|
||||
with get () = hdr this "HX-Trigger"
|
||||
|
||||
/// <summary>The <c>name</c> attribute of the triggered element if it exists</summary>
|
||||
[<Obsolete "HX-Trigger-Name is removed in v4; may be available via extension, but will be removed from this library">]
|
||||
member this.HxTriggerName
|
||||
with get () = hdr this "HX-Trigger-Name"
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
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.8**
|
||||
**htmx version: 4.0.0-alpha6**
|
||||
|
||||
_Upgrading from v1.x: the [migration guide](https://htmx.org/migration-guide-htmx-1/) does not currently specify any request or response header changes. This means that there are no required code changes in moving from v1.* to v2.*._
|
||||
_Upgrading from v2.x: the [migration guide](https://four.htmx.org/migration-guide-htmx-4/) lists changes for v4. For this package, the `HX-Trigger` and `HX-Trigger-Name` headers are marked obsolete. They are replaced by `HX-Source`, which provides the triggering tag name and `id` attribute. The `HX-Prompt` header has also been marked as obsolete, as the `hx-prompt` attribute which generated its content has been removed._
|
||||
|
||||
_Obsolete elements will be removed in the first production v4 release._
|
||||
|
||||
### Setup
|
||||
|
||||
@@ -18,9 +20,9 @@ To obtain a request header, using the `IHeaderDictionary` extension properties:
|
||||
```fsharp
|
||||
let myHandler : HttpHander =
|
||||
fun next ctx ->
|
||||
match ctx.HxPrompt with
|
||||
| Some prompt -> ... // do something with the text the user provided
|
||||
| None -> ... // no text provided
|
||||
match ctx.Target with
|
||||
| Some elt -> ... // do something with id of the target element
|
||||
| None -> ... // no target element provided
|
||||
```
|
||||
|
||||
To set a response header:
|
||||
|
||||
Reference in New Issue
Block a user