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", "data", "hx" then value.map { |k, v| tag_option("#{key}-#{k}", v) } when "class" then tag_option("class", class_value(value)) else tag_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.