PhxComponentHelpers.set_attributes

You're seeing just the function set_attributes, go back to PhxComponentHelpers module for more information.
Link to this function

set_attributes(assigns, attributes, opts \\ [])

View Source

Extends assigns with raw_* attributes that can be interpolated within your component markup.

Parameters

  • assigns - your component assigns
  • attributes - 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
  • :data - when true, HTML attributes are prefixed with data-
  • :into - merges all assigns in a single one that can be interpolated at once

Example

assigns
|> set_attributes(
    [:id, :name, label: "default label"],
    required: [:id, :name],
    into: :attributes
  )
|> set_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.