PhxComponentHelpers.set_prefixed_attributes
You're seeing just the function
set_prefixed_attributes
, go back to PhxComponentHelpers module for more information.
Extends assigns with prefixed attributes that can be interpolated within your component markup. It will automatically detect any attribute prefixed by any of the given prefixes from input assigns.
Can be used for intance to easily map alpinejs
html attributes.
Parameters
assigns
- your component assignsprefixes
- a list of prefix as binaries
Options
:init
- a list of attributes that will be initialized if absent from assigns:required
- raises if required attributes are absent from assigns:into
- merges all assigns in a single one that can be interpolated at once
Example
assigns
|> set_prefixed_attributes(
["@click", "x-bind:"],
required: ["x-bind:class"],
into: :alpine_attributes
)
assigns
now contains @raw_click
, @raw_x-bind:class
and @raw_alpine_attributes
.