class RBX::OptionMarshaller
OptionMarshaller is a class that is used for serializing a hash into html tag attributes.
Public Class Methods
Source
# File rbxrb/lib/rbx/option_marshaller.rb, line 30 def tag_kwargs(options) options.reject { |k, _v| k.empty? }.map do |key, value| case key.to_s when "aria" then aria_attribute(value) when "data" then data_attribute(value) when "class" then class_attribute(value) when "hx" then hx_attribute(value) else boolean_or_option(key, value) end end.flatten.compact.join(" ") end
Marshal a hash into html tag attributes. If the key is aria, data, or class it will also spread that data creatively like data-key="true" from {data: {key: true}} and for class it will only include the class name if the value is truthy.