Update for v2 beta 1

This commit is contained in:
Daniel J. Summers 2024-03-18 20:03:18 -04:00
parent bdb7255a1c
commit 4f6bb8367a
7 changed files with 50 additions and 47 deletions

View File

@ -25,9 +25,10 @@ A server may want to respond to a request that originated from htmx differently
// "view" can be whatever your view engine needs for the body of the page
let result view : HttpHandler =
fun next ctx ->
match ctx.Request.IsHtmx && not ctx.Request.IsHtmxRefresh with
| true -> partial view
| false -> full view
if ctx.Request.IsHtmx && not ctx.Request.IsHtmxRefresh then
partial view
else
full view
```
htmx also utilizes [response headers](https://htmx.org/docs/#response_headers) to affect client-side behavior. For each of these, this library provides `HttpHandler`s that can be chained along with the response. As an example, if the server returns a redirect response (301, 302, 303, 307), the `XMLHttpRequest` handler on the client will follow the redirection before htmx can do anything with it. To redirect to a new page, you would return an OK (200) response with an `HX-Redirect` header set in the response.
@ -49,7 +50,9 @@ As an example, creating a `div` that loads data once the HTML is rendered:
```fsharp
let autoload =
div [ _hxGet "/lazy-load-data"; _hxTrigger "load" ] [ str "Loading..." ]
div [ _hxGet "/lazy-load-data"; _hxTrigger HxTrigger.Load ] [
str "Loading..."
]
```
_(As `hx-boost="true"` is the usual desire for boosting, `_hxBoost` implies true. To disable it for an element, use `_hxNoBoost` instead.)_

View File

@ -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-alpha2**
**htmx version: 2.0.0-beta1**

View File

@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>alpha2</VersionSuffix>
<PackageReleaseNotes>Update script tags to pull htmx 2.0.0-alpha2; remove deprecated _hxOn attribute</PackageReleaseNotes>
<VersionSuffix>beta1</VersionSuffix>
<PackageReleaseNotes>Update script tags to pull htmx 2.0.0-beta1</PackageReleaseNotes>
<Authors>danieljsummers</Authors>
<Company>Bit Badger Solutions</Company>
<PackageProjectUrl>https://github.com/bit-badger/Giraffe.Htmx</PackageProjectUrl>
@ -13,6 +13,6 @@
<RepositoryType>Git</RepositoryType>
<Copyright>MIT License</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Giraffe htmx alpha</PackageTags>
<PackageTags>Giraffe htmx beta</PackageTags>
</PropertyGroup>
</Project>

View File

@ -2,9 +2,9 @@
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-alpha2**
**htmx version: 2.0.0-beta1**
_Note that htmx 2.0 is an ALPHA 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._
_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._
### Setup

View File

@ -820,14 +820,14 @@ let script =
let html = RenderView.AsString.htmlNode Script.minified
Expect.equal
html
"""<script src="https://unpkg.com/htmx.org@2.0.0-alpha2" integrity="sha384-291pOdLqD0RmU6d5pyz/xmHmZZPhEv465X4AJDWvc8n0KrWrD65qaf2fk0xmsrJe" crossorigin="anonymous"></script>"""
"""<script src="https://unpkg.com/htmx.org@2.0.0-beta1" integrity="sha384-T4bn1KcRXtR+kI4M+oOdhVp039Q5Oyq59dsDYJuSBCuHDbLA4iBpCSYaEKmGK5AU" crossorigin="anonymous"></script>"""
"Minified script tag is incorrect"
}
test "unminified succeeds" {
let html = RenderView.AsString.htmlNode Script.unminified
Expect.equal
html
"""<script src="https://unpkg.com/htmx.org@2.0.0-alpha2/dist/htmx.js" integrity="sha384-4Owd2qj8qFNBZ8QiR2ItYnNuMGgpOxaDT1uuRJXziuB1lvvKGYA/Lxy/oVM6q3h1" crossorigin="anonymous"></script>"""
"""<script src="https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js" integrity="sha384-LT44Cr6uyeKreQr6d0kPh+o3cuLJ3Q+ysV1YzehXD6D9pdpF/7DMiUDx7hrlPiNi" crossorigin="anonymous"></script>"""
"Unminified script tag is incorrect"
}
]

View File

@ -444,14 +444,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-alpha2"
_integrity "sha384-291pOdLqD0RmU6d5pyz/xmHmZZPhEv465X4AJDWvc8n0KrWrD65qaf2fk0xmsrJe"
script [ _src "https://unpkg.com/htmx.org@2.0.0-beta1"
_integrity "sha384-T4bn1KcRXtR+kI4M+oOdhVp039Q5Oyq59dsDYJuSBCuHDbLA4iBpCSYaEKmGK5AU"
_crossorigin "anonymous" ] []
/// Script tag to load the unminified version from unpkg.com
let unminified =
script [ _src "https://unpkg.com/htmx.org@2.0.0-alpha2/dist/htmx.js"
_integrity "sha384-4Owd2qj8qFNBZ8QiR2ItYnNuMGgpOxaDT1uuRJXziuB1lvvKGYA/Lxy/oVM6q3h1"
script [ _src "https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js"
_integrity "sha384-LT44Cr6uyeKreQr6d0kPh+o3cuLJ3Q+ysV1YzehXD6D9pdpF/7DMiUDx7hrlPiNi"
_crossorigin "anonymous" ] []

View File

@ -2,9 +2,9 @@
This package enables [htmx](https://htmx.org) support within the [Giraffe](https://giraffe.wiki) view engine.
**htmx version: 2.0.0-alpha2**
**htmx version: 2.0.0-beta1**
_Note that this is an ALPHA release of htmx 2.0; see [the migration guide](https://v2-0v2-0.htmx.org/migration-guide-htmx-1/) for changes_
_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_
### Setup