Add HX-Retarget header (#2)
This commit is contained in:
parent
5906f3b295
commit
9fcba06e75
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>0.9.2</VersionPrefix>
|
||||
<PackageReleaseNotes>Complete view engine modules; add READMEs</PackageReleaseNotes>
|
||||
<VersionPrefix>0.9.3</VersionPrefix>
|
||||
<PackageReleaseNotes>Add support for HX-Retarget header (added in htmx 1.6.1)</PackageReleaseNotes>
|
||||
<Authors>danieljsummers</Authors>
|
||||
<Company>Bit Badger Solutions</Company>
|
||||
<PackageProjectUrl>https://github.com/bit-badger/Giraffe.Htmx</PackageProjectUrl>
|
||||
|
|
|
@ -250,6 +250,17 @@ module HandlerTests =
|
|||
Assert.Equal ("false", dic.["HX-Refresh"].[0])
|
||||
}
|
||||
|
||||
[<Fact>]
|
||||
let ``withHxRetarget succeeds`` () =
|
||||
let ctx = Substitute.For<HttpContext> ()
|
||||
let dic = HeaderDictionary ()
|
||||
ctx.Response.Headers.ReturnsForAnyArgs dic |> ignore
|
||||
task {
|
||||
let! _ = withHxRetarget "#somewhereElse" next ctx
|
||||
Assert.True (dic.ContainsKey "HX-Retarget")
|
||||
Assert.Equal ("#somewhereElse", dic.["HX-Retarget"].[0])
|
||||
}
|
||||
|
||||
[<Fact>]
|
||||
let ``withHxTrigger succeeds`` () =
|
||||
let ctx = Substitute.For<HttpContext> ()
|
||||
|
|
|
@ -74,6 +74,10 @@ module Handlers =
|
|||
let withHxRefresh : bool -> HttpHandler =
|
||||
toLowerBool >> setHttpHeader "HX-Refresh"
|
||||
|
||||
/// Allows you to override the `hx-target` attribute
|
||||
let withHxRetarget : string -> HttpHandler =
|
||||
setHttpHeader "HX-Retarget"
|
||||
|
||||
/// Allows you to trigger a single client side event
|
||||
let withHxTrigger : string -> HttpHandler =
|
||||
setHttpHeader "HX-Trigger"
|
||||
|
|
Loading…
Reference in New Issue
Block a user