htmx 0.2.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +12 -4
- data/htmx.gemspec +1 -1
- data/lib/htmx/headers/request.rb +12 -8
- data/lib/htmx/headers/response.rb +4 -0
- data/lib/htmx/prefixer.rb +1 -1
- data/lib/htmx.rb +5 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65dd7e62da5f84c05bee2472e6894ad14b93b3ed302102d77c05538fb0c95edb
|
4
|
+
data.tar.gz: cae8715c6576a53c2e0adbeb4206f795add1ef4360eda4b6503046610caa374e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62e06efdbcb28a141d685397a1c1bd90b25f8f619a921b974a07d92ee4cd5ea60737de5563e1fe5df28b536d8c251ec0a8aa4e8e1bc0e32986c8f2d6296cb921
|
7
|
+
data.tar.gz: 2c41fb9b95e4cd6c476aecc1264c61319cdfa138c760b23be5697616738092a42212ef5fe738fb4111a9fbbc73dde2accdac9936275553238a376ccdfa747e10
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -84,7 +84,7 @@ One of the first tasks you'll want to tackle, when working with the {htmx_link}
|
|
84
84
|
|
85
85
|
[source,ruby]
|
86
86
|
----
|
87
|
-
|
87
|
+
tag.button(
|
88
88
|
"Delete",
|
89
89
|
class: "button decline",
|
90
90
|
type: "submit",
|
@@ -111,7 +111,7 @@ As shown above, building HTMX attributes takes minimal effort but if you'd prefe
|
|
111
111
|
----
|
112
112
|
prefixer = HTMX::Prefixer.new "data-hx"
|
113
113
|
|
114
|
-
|
114
|
+
tag.button(
|
115
115
|
"Delete",
|
116
116
|
class: "button decline",
|
117
117
|
type: "submit",
|
@@ -151,13 +151,21 @@ HTMX::Prefixer.new "bogus"
|
|
151
151
|
# Invalid prefix: "bogus". Use: "hx" or "data-hx". (HTMX::Error)
|
152
152
|
----
|
153
153
|
|
154
|
+
Some {htmx_link} attributes use dashes. For those situations, you can use strings for keys or underscored symbols to produce the correct HTMX syntax. Here's and example using both a string and symbol for keys:
|
155
|
+
|
156
|
+
[source,ruby]
|
157
|
+
----
|
158
|
+
HTMX["swap-oob" => true, push_url: "/demo/123"]
|
159
|
+
# {"hx-swap-oob"=>true, "hx-push-url"=>"/demo/123"}
|
160
|
+
----
|
161
|
+
|
154
162
|
=== HTTP Headers
|
155
163
|
|
156
164
|
When working with HTTP requests/responses, especially HTTP headers, there are a few objects that can parse and make the data easier to work with. These objects are named accordingly: request and response. Here's how to use them.
|
157
165
|
|
158
166
|
==== Request
|
159
167
|
|
160
|
-
The request object allows you to obtain
|
168
|
+
The request object allows you to obtain a {data_link} object to interact with when parsing link:https://htmx.org/reference/#request_headers[HTMX HTTP request headers]. Example:
|
161
169
|
|
162
170
|
[source,ruby]
|
163
171
|
----
|
@@ -195,7 +203,7 @@ With the above, the `.for` method plucks out only the HTMX specific headers whic
|
|
195
203
|
|
196
204
|
==== Response
|
197
205
|
|
198
|
-
The response object allows you to obtain
|
206
|
+
The response object allows you to obtain a {data_link} object to interact with when parsing link:https://htmx.org/reference/#response_headers[HTMX HTTP response headers]. Example:
|
199
207
|
|
200
208
|
[source,ruby]
|
201
209
|
----
|
data/htmx.gemspec
CHANGED
data/lib/htmx/headers/request.rb
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
module HTMX
|
4
4
|
module Headers
|
5
5
|
REQUEST_KEY_MAP = {
|
6
|
-
"
|
7
|
-
"
|
8
|
-
"
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"
|
12
|
-
"
|
13
|
-
"
|
6
|
+
"HTTP_HX_BOOSTED" => :boosted,
|
7
|
+
"HTTP_HX_CURRENT_URL" => :current_url,
|
8
|
+
"HTTP_HX_HISTORY_RESTORE_REQUEST" => :history_restore_request,
|
9
|
+
"HTTP_HX_PROMPT" => :prompt,
|
10
|
+
"HTTP_HX_REQUEST" => :request,
|
11
|
+
"HTTP_HX_TARGET" => :target,
|
12
|
+
"HTTP_HX_TRIGGER_NAME" => :trigger_name,
|
13
|
+
"HTTP_HX_TRIGGER" => :trigger
|
14
14
|
}.freeze
|
15
15
|
|
16
16
|
# Models the supported HTMX request headers.
|
@@ -28,6 +28,10 @@ module HTMX
|
|
28
28
|
new(**attributes.slice(*key_map.keys).transform_keys!(key_map))
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.key_for(header, key_map: REQUEST_KEY_MAP) = key_map.fetch header
|
32
|
+
|
33
|
+
def self.header_for(key, key_map: REQUEST_KEY_MAP.invert) = key_map.fetch key
|
34
|
+
|
31
35
|
def initialize boosted: nil,
|
32
36
|
current_url: nil,
|
33
37
|
history_restore_request: nil,
|
@@ -32,6 +32,10 @@ module HTMX
|
|
32
32
|
new(**attributes.slice(*key_map.keys).transform_keys!(key_map))
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.key_for(header, key_map: RESPONSE_KEY_MAP) = key_map.fetch header
|
36
|
+
|
37
|
+
def self.header_for(key, key_map: RESPONSE_KEY_MAP.invert) = key_map.fetch key
|
38
|
+
|
35
39
|
def initialize location: nil,
|
36
40
|
push_url: nil,
|
37
41
|
redirect: nil,
|
data/lib/htmx/prefixer.rb
CHANGED
data/lib/htmx.rb
CHANGED
@@ -2,13 +2,17 @@
|
|
2
2
|
|
3
3
|
require "zeitwerk"
|
4
4
|
|
5
|
-
Zeitwerk::Loader.
|
5
|
+
Zeitwerk::Loader.new.then do |loader|
|
6
6
|
loader.inflector.inflect "htmx" => "HTMX"
|
7
|
+
loader.tag = File.basename __FILE__, ".rb"
|
8
|
+
loader.push_dir __dir__
|
7
9
|
loader.setup
|
8
10
|
end
|
9
11
|
|
10
12
|
# Main namespace.
|
11
13
|
module HTMX
|
14
|
+
def self.loader(registry = Zeitwerk::Registry) = registry.loader_for __FILE__
|
15
|
+
|
12
16
|
def self.[](...)
|
13
17
|
@prefixer ||= Prefixer.new
|
14
18
|
@prefixer.call(...)
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htmx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-
|
38
|
+
date: 2023-10-01 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: refinements
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.4.
|
111
|
+
rubygems_version: 3.4.20
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: An augmenter and companion to the HTMX JavaScript library.
|
metadata.gz.sig
CHANGED
Binary file
|