Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Htmx v1.9.6 #3

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/HelloWorld/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let handleHtml : HttpHandler =
Templates.html5 "en"
[
Elem.link [ Attr.href "style.css"; Attr.rel "stylesheet" ]
Elem.script [ Attr.src "https://unpkg.com/htmx.org@1.8.0"] []
Elem.script [ Attr.src Script.src ] []
]
[
Elem.h1 [] [
Expand Down
7 changes: 6 additions & 1 deletion src/Falco.Htmx/Extensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ module Response =

// Allows you to trigger client side events, see the documentation for more info
let withHxTriggerAfterSwap : HttpResponseModifier =
Response.withHeaders [ "HX-Trigger-After-Swap", _trueValue ]
Response.withHeaders [ "HX-Trigger-After-Swap", _trueValue ]

/// A CSS selector that allows you to choose which part of the response is used to be swapped in.
/// see the documentation for more info
let withHxReselect (selector: string) : HttpResponseModifier =
Response.withHeaders [ "HX-Reselect", selector ]
4 changes: 4 additions & 0 deletions src/Falco.Htmx/Htmx.fs
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,7 @@ type DisinheritOption =
| AllAttributes -> "*"
| ExcludeAttributes [] -> "*"
| ExcludeAttributes names -> String.Join(" ", names)

module Script =
/// The script of the version of HTMX this library is written for.
let src = "https://unpkg.com/htmx.org@1.9.6"
15 changes: 14 additions & 1 deletion src/Falco.Htmx/Hx.fs
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,17 @@ let sync (targetOption : TargetOption, syncOption : SyncOption option) =
| Some sync' -> String.Concat([ target'; ":"; SyncOption.AsString sync' ])
| None -> target'

Attr.create "hx-sync" attrValue
Attr.create "hx-sync" attrValue

/// Whether to force elements to validate themselves before a request
let validate (value: bool) = Attr.create "hx-validate" (string value)

/// Whether to prevent sensitive data being saved to the history cache
let history (value: bool) = Attr.create "hx-history" (string value)

/// Handle any event with a script inline
let on eventName script = Attr.create $"hx-on:{eventName}"

/// adds the `disabled` attribute to the specified elements while a request is in flight
let disabledElement (targetOption: TargetOption) =
Attr.create "hx-disabled-elt" (TargetOption.AsString targetOption)