PhxComponentHelpers.set_prefixed_attributes

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

set_prefixed_attributes(assigns, prefixes, opts \\ [])

View Source

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 assigns
  • prefixes - 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.