Surface.Components.Context (surface v0.7.0) View Source

A built-in component that allows users to set and retrieve values from the context.

Properties

  • put :context_put, accumulate: true, default: [] - Puts a value into the context.

Usage

<Context put={scope, values}>
  ...
</Context>

Where:

  • scope - Optional. Is an atom representing the scope where the values will be stored. If no scope is provided, the value is stored at the root of the context map.

  • values- A keyword list containing the key-value pairs that will be stored in the context.

Examples

With scope:

<Context put={__MODULE__, form: @form}>
  ...
</Context>

Without scope:

<Context put={key1: @value1, key2: "some other value"}>
  ...
</Context>
  • get :context_get, accumulate: true, default: [] - Retrieves a set of values from the context binding them to local variables.

Usage

<Context get={scope, bindings}>
  ...
</Context>

Where:

  • scope - Optional. Is an atom representing the scope where the values will be stored. If no scope is provided, the value is stored at the root of the context map.

  • bindings- A keyword list of bindings that will be retrieved from the context as local variables.

Examples

<Context
  get={Form, form: form}
  get={Field, field: my_field}>
  <MyTextInput form={form} field={my_field} />
</Context>

Slots

  • default, required: true - The content of the <Context>

Link to this section Summary

Functions

Callback implementation for Surface.Component.render/1.

Callback implementation for c:Surface.BaseComponent.transform/1.

Link to this section Functions

Callback implementation for Surface.Component.render/1.

Callback implementation for c:Surface.BaseComponent.transform/1.