Class: HTMX::Prefixer
- Inherits:
-
Object
- Object
- HTMX::Prefixer
- Defined in:
- lib/htmx/prefixer.rb
Overview
Prefixes HTML element attributes for proper consumption by the HTMX JavaScript library.
Constant Summary collapse
- ALLOWED =
%w[hx data-hx].freeze
Instance Method Summary collapse
- #call(**attributes) ⇒ Object
-
#initialize(default = "hx", allowed: ALLOWED) ⇒ Prefixer
constructor
A new instance of Prefixer.
Constructor Details
Instance Method Details
#call(**attributes) ⇒ Object
18 |
# File 'lib/htmx/prefixer.rb', line 18 def call(**attributes) = attributes.transform_keys! { |key| "#{default}-#{key}".tr "_", "-" } |