Compare commits
5 Commits
v1.9.11
...
v2.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f6bb8367a | |||
| bdb7255a1c | |||
| 9276db7ffe | |||
| 452f15b2d4 | |||
| 16355e8f58 |
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@@ -2,9 +2,10 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [ "main", "htmx-version-2" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
@@ -35,7 +36,7 @@ jobs:
|
|||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v3
|
||||||
with:
|
with:
|
||||||
dotnet-version: "7.0"
|
dotnet-version: "8.0"
|
||||||
- name: Package Common library
|
- name: Package Common library
|
||||||
run: dotnet pack src/Common/Giraffe.Htmx.Common.fsproj -c Release
|
run: dotnet pack src/Common/Giraffe.Htmx.Common.fsproj -c Release
|
||||||
- name: Move Common package
|
- name: Move Common package
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -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
|
// "view" can be whatever your view engine needs for the body of the page
|
||||||
let result view : HttpHandler =
|
let result view : HttpHandler =
|
||||||
fun next ctx ->
|
fun next ctx ->
|
||||||
match ctx.Request.IsHtmx && not ctx.Request.IsHtmxRefresh with
|
if ctx.Request.IsHtmx && not ctx.Request.IsHtmxRefresh then
|
||||||
| true -> partial view
|
partial view
|
||||||
| false -> full 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.
|
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
|
```fsharp
|
||||||
let autoload =
|
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.)_
|
_(As `hx-boost="true"` is the usual desire for boosting, `_hxBoost` implies true. To disable it for an element, use `_hxNoBoost` instead.)_
|
||||||
|
|||||||
@@ -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.
|
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: 1.9.10**
|
**htmx version: 2.0.0-beta1**
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
<VersionPrefix>1.9.10</VersionPrefix>
|
<VersionPrefix>2.0.0</VersionPrefix>
|
||||||
<PackageReleaseNotes>Update script tags to pull htmx 1.9.10; add support for hx-on:* attributes; require lowest FSharp.Core version; fix _hxDisabledElt spelling</PackageReleaseNotes>
|
<VersionSuffix>beta1</VersionSuffix>
|
||||||
|
<PackageReleaseNotes>Update script tags to pull htmx 2.0.0-beta1</PackageReleaseNotes>
|
||||||
<Authors>danieljsummers</Authors>
|
<Authors>danieljsummers</Authors>
|
||||||
<Company>Bit Badger Solutions</Company>
|
<Company>Bit Badger Solutions</Company>
|
||||||
<PackageProjectUrl>https://github.com/bit-badger/Giraffe.Htmx</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/bit-badger/Giraffe.Htmx</PackageProjectUrl>
|
||||||
@@ -12,6 +13,6 @@
|
|||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<Copyright>MIT License</Copyright>
|
<Copyright>MIT License</Copyright>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>Giraffe htmx</PackageTags>
|
<PackageTags>Giraffe htmx beta</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
This package enables server-side support for [htmx](https://htmx.org) within [Giraffe](https://giraffe.wiki) and ASP.NET's `HttpContext`.
|
This package enables server-side support for [htmx](https://htmx.org) within [Giraffe](https://giraffe.wiki) and ASP.NET's `HttpContext`.
|
||||||
|
|
||||||
**htmx version: 1.9.10**
|
**htmx version: 2.0.0-beta1**
|
||||||
|
|
||||||
|
_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
|
### Setup
|
||||||
|
|
||||||
1. Install the package.
|
1. Install the package (must use `--Prerelease` flag).
|
||||||
2. Prior to using the request header extension properties or the header-setting `HttpHandler`s, `open Giraffe.Htmx`.
|
2. Prior to using the request header extension properties or the header-setting `HttpHandler`s, `open Giraffe.Htmx`.
|
||||||
|
|
||||||
### Use
|
### Use
|
||||||
|
|||||||
@@ -820,14 +820,14 @@ let script =
|
|||||||
let html = RenderView.AsString.htmlNode Script.minified
|
let html = RenderView.AsString.htmlNode Script.minified
|
||||||
Expect.equal
|
Expect.equal
|
||||||
html
|
html
|
||||||
"""<script src="https://unpkg.com/htmx.org@1.9.10" integrity="sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC" 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"
|
"Minified script tag is incorrect"
|
||||||
}
|
}
|
||||||
test "unminified succeeds" {
|
test "unminified succeeds" {
|
||||||
let html = RenderView.AsString.htmlNode Script.unminified
|
let html = RenderView.AsString.htmlNode Script.unminified
|
||||||
Expect.equal
|
Expect.equal
|
||||||
html
|
html
|
||||||
"""<script src="https://unpkg.com/htmx.org@1.9.10/dist/htmx.js" integrity="sha384-j1TtLExqttdT7C3Z/rJy8UZcCGiuqwwN9++coZ6up+5O/l2FHdp3IGfuJOvst6d1" 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"
|
"Unminified script tag is incorrect"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -979,18 +979,6 @@ let renderFragment =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
#nowarn "44"
|
|
||||||
|
|
||||||
/// Tests for the HtmxAttrs module
|
|
||||||
let deprecatedAttributes =
|
|
||||||
testList "Deprecated Attributes" [
|
|
||||||
test "_hxOn succeeds" {
|
|
||||||
let newLine = "\n"
|
|
||||||
strong [ _hxOn "submit: alert('oops')\nclick: alert('howdy!')" ] []
|
|
||||||
|> shouldRender $"""<strong hx-on="submit: alert('oops'){newLine}click: alert('howdy!')"></strong>"""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
/// All tests in this module
|
/// All tests in this module
|
||||||
let allTests =
|
let allTests =
|
||||||
testList "ViewEngine.Htmx" [
|
testList "ViewEngine.Htmx" [
|
||||||
@@ -1004,5 +992,4 @@ let allTests =
|
|||||||
attributes
|
attributes
|
||||||
script
|
script
|
||||||
renderFragment
|
renderFragment
|
||||||
deprecatedAttributes
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -317,8 +317,6 @@ 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
|
||||||
|
|
||||||
open System
|
|
||||||
|
|
||||||
/// Attributes and flags for htmx
|
/// Attributes and flags for htmx
|
||||||
[<AutoOpen>]
|
[<AutoOpen>]
|
||||||
module HtmxAttrs =
|
module HtmxAttrs =
|
||||||
@@ -368,10 +366,6 @@ module HtmxAttrs =
|
|||||||
/// Overrides a previous `hx-boost`
|
/// Overrides a previous `hx-boost`
|
||||||
let _hxNoBoost = attr "hx-boost" "false"
|
let _hxNoBoost = attr "hx-boost" "false"
|
||||||
|
|
||||||
/// Attach an event handler for DOM or htmx events
|
|
||||||
[<Obsolete "This will be removed in htmx 2; use _hxOnEvent or _hxOnHxEvent instead">]
|
|
||||||
let _hxOn = attr "hx-on"
|
|
||||||
|
|
||||||
/// Attach an event handler for DOM events
|
/// Attach an event handler for DOM events
|
||||||
let _hxOnEvent evtName =
|
let _hxOnEvent evtName =
|
||||||
attr $"hx-on:%s{evtName}"
|
attr $"hx-on:%s{evtName}"
|
||||||
@@ -450,14 +444,14 @@ module Script =
|
|||||||
|
|
||||||
/// Script tag to load the minified version from unpkg.com
|
/// Script tag to load the minified version from unpkg.com
|
||||||
let minified =
|
let minified =
|
||||||
script [ _src "https://unpkg.com/htmx.org@1.9.10"
|
script [ _src "https://unpkg.com/htmx.org@2.0.0-beta1"
|
||||||
_integrity "sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC"
|
_integrity "sha384-T4bn1KcRXtR+kI4M+oOdhVp039Q5Oyq59dsDYJuSBCuHDbLA4iBpCSYaEKmGK5AU"
|
||||||
_crossorigin "anonymous" ] []
|
_crossorigin "anonymous" ] []
|
||||||
|
|
||||||
/// Script tag to load the unminified version from unpkg.com
|
/// Script tag to load the unminified version from unpkg.com
|
||||||
let unminified =
|
let unminified =
|
||||||
script [ _src "https://unpkg.com/htmx.org@1.9.10/dist/htmx.js"
|
script [ _src "https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js"
|
||||||
_integrity "sha384-j1TtLExqttdT7C3Z/rJy8UZcCGiuqwwN9++coZ6up+5O/l2FHdp3IGfuJOvst6d1"
|
_integrity "sha384-LT44Cr6uyeKreQr6d0kPh+o3cuLJ3Q+ysV1YzehXD6D9pdpF/7DMiUDx7hrlPiNi"
|
||||||
_crossorigin "anonymous" ] []
|
_crossorigin "anonymous" ] []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
This package enables [htmx](https://htmx.org) support within the [Giraffe](https://giraffe.wiki) view engine.
|
This package enables [htmx](https://htmx.org) support within the [Giraffe](https://giraffe.wiki) view engine.
|
||||||
|
|
||||||
**htmx version: 1.9.10**
|
**htmx version: 2.0.0-beta1**
|
||||||
|
|
||||||
|
_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
|
### Setup
|
||||||
|
|
||||||
1. Install the package.
|
1. Install the package (must use `--Prelease` flag).
|
||||||
2. Prior to using the attribute or support modules, `open Giraffe.ViewEngine.Htmx`.
|
2. Prior to using the attribute or support modules, `open Giraffe.ViewEngine.Htmx`.
|
||||||
|
|
||||||
### Use
|
### Use
|
||||||
|
|||||||
Reference in New Issue
Block a user