Module: HTMX::Headers
- Defined in:
- lib/htmx/headers/request.rb,
lib/htmx/headers/response.rb
Constant Summary collapse
- REQUEST_KEY_MAP =
{ "HTTP_HX_BOOSTED" => :boosted, "HTTP_HX_CURRENT_URL" => :current_url, "HTTP_HX_HISTORY_RESTORE_REQUEST" => :history_restore_request, "HTTP_HX_PROMPT" => :prompt, "HTTP_HX_REQUEST" => :request, "HTTP_HX_TARGET" => :target, "HTTP_HX_TRIGGER_NAME" => :trigger_name, "HTTP_HX_TRIGGER" => :trigger }.freeze
- Request =
Models the supported HTMX request headers.
Data.define( :boosted, :current_url, :history_restore_request, :prompt, :request, :target, :trigger_name, :trigger ) do def self.for(key_map: REQUEST_KEY_MAP, **attributes) new(**attributes.slice(*key_map.keys).transform_keys!(key_map)) end def self.key_for(header, key_map: REQUEST_KEY_MAP) = key_map.fetch header def self.header_for(key, key_map: REQUEST_KEY_MAP.invert) = key_map.fetch key def initialize boosted: nil, current_url: nil, history_restore_request: nil, prompt: nil, request: nil, target: nil, trigger_name: nil, trigger: nil super end end
- RESPONSE_KEY_MAP =
{ "HX-Location" => :location, "HX-Push-Url" => :push_url, "HX-Redirect" => :redirect, "HX-Refresh" => :refresh, "HX-Replace-Url" => :replace_url, "HX-Reswap" => :reswap, "HX-Retarget" => :retarget, "HX-Trigger" => :trigger, "HX-Trigger-After-Settle" => :trigger_after_settle, "HX-Trigger-After-Swap" => :trigger_after_swap }.freeze
- Response =
Models the supported HTMX response headers.
Data.define( :location, :push_url, :redirect, :refresh, :replace_url, :reswap, :retarget, :trigger, :trigger_after_settle, :trigger_after_swap ) do def self.for(key_map: RESPONSE_KEY_MAP, **attributes) new(**attributes.slice(*key_map.keys).transform_keys!(key_map)) end def self.key_for(header, key_map: RESPONSE_KEY_MAP) = key_map.fetch header def self.header_for(key, key_map: RESPONSE_KEY_MAP.invert) = key_map.fetch key def initialize location: nil, push_url: nil, redirect: nil, refresh: nil, replace_url: nil, reswap: nil, retarget: nil, trigger: nil, trigger_after_settle: nil, trigger_after_swap: nil super end end