PhxComponentHelpers.set_component_attributes
You're seeing just the function
set_component_attributes
, go back to PhxComponentHelpers module for more information.
Extends assigns with raw_* attributes that can be interpolated within your component markup.
Parameters
assigns
- your component assignsattributes
- a list of attributes (atoms) that will be fetched from assigns. Attributes can either be single atoms or tuples in the form{:atom, default}
to provide default values.
Options
:required
- raises if required attributes are absent from assigns:json
- when true, will JSON encode the assign value:into
- merges all assigns in a single one that can be interpolated at once
Example
assigns
|> set_component_attributes(
[:id, :name, label: "default label"],
required: [:id, :name],
into: :attributes
)
|> set_component_attributes([:value], json: true)
assigns
now contains @raw_id
, @raw_name
, @raw_label
and @raw_value
.
It also contains @raw_attributes
which holds the values if :id
, :name
and :label
.