Add hx-history attribute

Add .NET 7 support
This commit is contained in:
Daniel J. Summers 2023-01-17 20:41:54 -05:00
parent 061f6e5a4e
commit 277d93dd99
6 changed files with 19 additions and 12 deletions

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. 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.8.4** **htmx version: 1.8.5**

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<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>
<TargetFramework>net6.0</TargetFramework> <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<VersionPrefix>1.8.4</VersionPrefix> <VersionPrefix>1.8.5</VersionPrefix>
<PackageReleaseNotes>Support new hx-validate attribute in htmx 1.8.1; add support for fragment rendering</PackageReleaseNotes> <PackageReleaseNotes>Support new hx-history attribute in htmx 1.8.5; add .NET 7 support</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>

View File

@ -2,7 +2,7 @@
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.8.4** **htmx version: 1.8.5**
### Setup ### Setup

View File

@ -333,6 +333,10 @@ module Attributes =
figure [ _hxHeaders """{ "X-Special-Header": "some-header" }""" ] [] figure [ _hxHeaders """{ "X-Special-Header": "some-header" }""" ] []
|> shouldRender """<figure hx-headers="{ &quot;X-Special-Header&quot;: &quot;some-header&quot; }"></figure>""" |> shouldRender """<figure hx-headers="{ &quot;X-Special-Header&quot;: &quot;some-header&quot; }"></figure>"""
[<Fact>]
let ``_hxHistory succeeds`` () =
span [ _hxHistory "false" ] [] |> shouldRender """<span hx-history="false"></span>"""
[<Fact>] [<Fact>]
let ``_hxHistoryElt succeeds`` () = let ``_hxHistoryElt succeeds`` () =
table [ _hxHistoryElt ] [] |> shouldRender """<table hx-history-elt></table>""" table [ _hxHistoryElt ] [] |> shouldRender """<table hx-history-elt></table>"""
@ -434,14 +438,14 @@ module Script =
let ``Script.minified succeeds`` () = let ``Script.minified succeeds`` () =
let html = RenderView.AsString.htmlNode Script.minified let html = RenderView.AsString.htmlNode Script.minified
Assert.Equal Assert.Equal
("""<script src="https://unpkg.com/htmx.org@1.8.4" integrity="sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" crossorigin="anonymous"></script>""", ("""<script src="https://unpkg.com/htmx.org@1.8.5" integrity="sha384-7aHh9lqPYGYZ7sTHvzP1t3BAfLhYSTy9ArHdP3Xsr9/3TlGurYgcPBoFmXX2TX/w" crossorigin="anonymous"></script>""",
html) html)
[<Fact>] [<Fact>]
let ``Script.unminified succeeds`` () = let ``Script.unminified succeeds`` () =
let html = RenderView.AsString.htmlNode Script.unminified let html = RenderView.AsString.htmlNode Script.unminified
Assert.Equal Assert.Equal
("""<script src="https://unpkg.com/htmx.org@1.8.4/dist/htmx.js" integrity="sha384-sh63gh7zpjxu153RyKJ06Oy5HxIVl6cchze/dJOHulOI7u0sGZoC/CfQJHPODhFn" crossorigin="anonymous"></script>""", ("""<script src="https://unpkg.com/htmx.org@1.8.5/dist/htmx.js" integrity="sha384-VgGOQitu5eD5qAdh1QPLvPeTt1X4/Iw9B2sfYw+p3xtTumxaRv+onip7FX+P6q30" crossorigin="anonymous"></script>""",
html) html)

View File

@ -208,6 +208,9 @@ module HtmxAttrs =
/// Adds to the headers that will be submitted with the request /// Adds to the headers that will be submitted with the request
let _hxHeaders = attr "hx-headers" let _hxHeaders = attr "hx-headers"
/// Set to "false" to prevent pages with sensitive information from being stored in the history cache
let _hxHistory = attr "hx-history"
/// The element to snapshot and restore during history navigation /// The element to snapshot and restore during history navigation
let _hxHistoryElt = flag "hx-history-elt" let _hxHistoryElt = flag "hx-history-elt"
@ -286,14 +289,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.8.4" script [ _src "https://unpkg.com/htmx.org@1.8.5"
_integrity "sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" _integrity "sha384-7aHh9lqPYGYZ7sTHvzP1t3BAfLhYSTy9ArHdP3Xsr9/3TlGurYgcPBoFmXX2TX/w"
_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.8.4/dist/htmx.js" script [ _src "https://unpkg.com/htmx.org@1.8.5/dist/htmx.js"
_integrity "sha384-sh63gh7zpjxu153RyKJ06Oy5HxIVl6cchze/dJOHulOI7u0sGZoC/CfQJHPODhFn" _integrity "sha384-VgGOQitu5eD5qAdh1QPLvPeTt1X4/Iw9B2sfYw+p3xtTumxaRv+onip7FX+P6q30"
_crossorigin "anonymous" ] [] _crossorigin "anonymous" ] []

View File

@ -2,7 +2,7 @@
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.8.4** **htmx version: 1.8.5**
### Setup ### Setup