/// Common definitions shared between attribute values and response headers
[]
module Giraffe.Htmx.Common
/// The version of htmx embedded in the package
let HtmxVersion = "4.0.0-alpha6"
/// The path for the provided htmx script
let internal htmxLocalScript = $"/_content/Giraffe.Htmx.Common/htmx.min.js?ver={HtmxVersion}"
/// Serialize a list of key/value pairs to JSON (very rudimentary)
/// The key/value pairs to be serialized to JSON
/// A string with the key/value pairs serialized to JSON
let internal toJson (pairs: (string * string) list) =
pairs
|> List.map (fun pair -> sprintf "\"%s\": \"%s\"" (fst pair) ((snd pair).Replace ("\"", "\\\"")))
|> String.concat ", "
|> sprintf "{ %s }"
/// Convert a boolean to lowercase "true" or "false"
/// The boolean value to convert
/// "true" for true, "false" for false
let internal toLowerBool (boolValue: bool) =
(string boolValue).ToLowerInvariant()
/// Valid values for the hx-swap attribute / HX-Reswap header
/// May be combined with swap / scroll / show config)
/// Documentation
[]
module HxSwap =
/// The default, replace the inner HTML of the target element
[]
let InnerHtml = "innerHTML"
/// Replace the entire target element with the response
[]
let OuterHtml = "outerHTML"
/// Morph the inner HTML of the target to the new content
[]
let InnerMorph = "innerMorph"
/// Morph the outer HTML of the target to the new content
[]
let OuterMorph = "innerMorph"
/// Replace the text content of the target without parsing the response as HTML
[]
let TextContent = "textContent"
/// Insert the response before the target element
[]
let Before = "before"
/// Insert the response before the target element (pre-v4 name)
[]
let BeforeBegin = Before
/// Insert the response before the first child of the target element
[]
let Prepend = "prepend"
/// Insert the response before the first child of the target element (pre-v4 name)
[]
let AfterBegin = Prepend
/// Insert the response after the last child of the target element
[]
let Append = "append"
/// Insert the response after the last child of the target element (pre-v4 name)
[]
let BeforeEnd = Append
/// Insert the response after the target element
[]
let After = "after"
/// Insert the response after the target element (pre-v4 name)
[]
let AfterEnd = After
/// Delete the target element regardless of response
[]
let Delete = "delete"
/// Does not append content from response (out of band items will still be processed)
[]
let None = "none"
/// Update existing elements by id and add new ones
/// This requires the upsert extension
/// Extension
[]
let Upsert = "upsert"