v4, beta4 (#19)
- Update with header/attribute changes between alpha8 and beta4 - Add support for htmax script, attributes, headers, and extension config Reviewed-on: #19
This commit was merged in pull request #19.
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
This package enables [htmx](https://htmx.org) support within the [Giraffe](https://giraffe.wiki) view engine.
|
||||
|
||||
**htmx version: 4.0.0-alpha8**
|
||||
**htmx version: 4.0.0-beta4**
|
||||
|
||||
_Upgrading from v2.x: see [the migration guide](https://four.htmx.org/migration-guide-htmx-4/) for changes, which are plentiful. htmx switches from `XMLHTTPRequest` to `fetch`, and many changes are related to the new event cycle._
|
||||
_Upgrading from v2.x: see [the migration guide](https://four.htmx.org/docs/get-started/migration) for changes, which are plentiful. htmx switches from `XMLHTTPRequest` to `fetch`, and many changes are related to the new event cycle._
|
||||
|
||||
_Inheritance is now explicit; to have an attribute's value inherited to its children, wrap the attribute in `hxInherited` (ex. `hxInherited (_hxTarget "#main")`). Values can be appended to inherited values as well using the `hxAppend` modifier._
|
||||
|
||||
@@ -13,7 +13,8 @@ _Several constructs have been marked obsolete in this release, and will be remov
|
||||
### Setup
|
||||
|
||||
1. Install the package.
|
||||
2. Prior to using the attribute or support modules, `open Giraffe.ViewEngine.Htmx`.
|
||||
1. Prior to using the attribute or support modules, `open Giraffe.ViewEngine.Htmx`.
|
||||
1. If the client is using the `htmax` bundle, also `open Giraffe.ViewEngine.Htmax`.
|
||||
|
||||
### Use
|
||||
|
||||
@@ -34,7 +35,9 @@ Support modules include:
|
||||
- `HxTrigger`
|
||||
- `HxVals`
|
||||
|
||||
`Htmx.Script.local` creates an `XmlNode` to load the package-provided htmx library. There are also two `XmlNode`s that will load the htmx script from jsdelivr; `Htmx.Script.cdnMinified` loads the minified version, and `Htmx.Script.cdnUnminified` loads the unminified version (useful for debugging). When using the CDN nodes and a Content Security Policy (CSP) header, `cdn.jsdelivr.net` needs to be listed as an allowable `script-src`.
|
||||
`Htmx.Script.local` creates an `XmlNode` to load the package-provided htmx library. There are also two `XmlNode`s that will load the htmx script from jsdelivr; `Htmx.Script.cdnMinified` loads the minified version, and `Htmx.Script.cdnUnminified` loads the unminified version (useful for debugging). htmx v4 also distributes a "max" bundle which contains some common extensions; these are available with the same names under `Htmx.Script.Max`.
|
||||
|
||||
_NOTE: When using the CDN nodes and a Content Security Policy (CSP) header, `cdn.jsdelivr.net` needs to be listed as an allowable `script-src`._
|
||||
|
||||
This also supports [fragment rendering](https://bitbadger.solutions/blog/2022/fragment-rendering-in-giraffe-view-engine.html), providing the flexibility to render an entire template, or only a portion of it (based on the element's `id` attribute).
|
||||
|
||||
@@ -47,10 +50,10 @@ htmx's attributes and these attribute functions map one-to-one. There are two ex
|
||||
The htmx `hx-on` attribute supports multiple events if they are separated with a newline (`\n`) character. The value provided to this attribute will be attribute-escaped, but in testing, it was interpreted correctly.
|
||||
|
||||
The support modules contain named properties for known values (as illustrated with `HxTrigger.Load` above). A few of the modules are more than collections of names, though:
|
||||
- `HxRequest` has a `Configure` function, which takes a list of strings; the other functions in the module allow for configuring the request.
|
||||
- `HxConfig` has a `Configure` function, which takes a list of strings; the other functions in the module allow for configuring the request.
|
||||
|
||||
```fsharp
|
||||
HxRequest.Configure [ HxRequest.Timeout 500 ] |> _hxRequest
|
||||
HxConfig.Configure [ HxRequest.Timeout 500 ] |> _hxConfig
|
||||
```
|
||||
- `HxTrigger` is _(by far)_ the most complex of these modules. Most uses won't need that complexity; however, complex triggers can be defined by piping into or composing with other functions. For example, to define an event that responds to a shift-click anywhere on the document, with a delay of 3 seconds before firing:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user