module Primer::AttributesHelper
def merge_data(*hashes)
{ data: { foo: "bar" } }
@system_arguments,
@system_arguments[:data] = merge_aria(
hashes. Consider using this pattern in component initializers:
It's designed to be used to normalize and merge data information from system_arguments
=> { target: "foo bar" }
Eg. merge_data({ "data-target": "foo" }, { data: { target: "bar" } })
will combine these plural attributes into a composite string.
Certain data attributes can contain multiple values separated by spaces. merge_data
=> { foo: "true", bar: "true" }
Eg. merge_data({ "data-foo": "true" }, { data: { bar: "true" } })
each hash and returns them in the new hash.
Merges hashes that contain "data-*" keys and nested data: hashes. Removes keys from
def merge_data(*hashes) merge_prefixed_attribute_hashes( *hashes, prefix: :data, plural_keys: PLURAL_DATA_ATTRIBUTES ) end