PhoenixKitCatalogue. Export. Destination behaviour
(PhoenixKitCatalogue v0.9.0)
Copy Markdown
View Source
Behaviour for export destinations (e.g. PRO100, Universal).
Each destination module defines a key, a human-readable label, the list of
format options it supports, and a render/2 function that produces the
file content for a given format key and export context.
Adding a new destination
- Create a module that
@behaviour PhoenixKitCatalogue.Export.Destination. - Implement all four callbacks.
- Register it in
PhoenixKitCatalogue.Export.destinations/0.
Summary
Callbacks
Supported formats as [{key, label}] pairs.
key is an atom used when calling render/2; label is the display string.
Machine key for the destination (e.g. :pro100).
Human-readable label shown in the UI select.
Renders the export content.
Callbacks
Supported formats as [{key, label}] pairs.
key is an atom used when calling render/2; label is the display string.
@callback key() :: atom()
Machine key for the destination (e.g. :pro100).
@callback label() :: String.t()
Human-readable label shown in the UI select.
@callback render(format_key :: atom(), ctx :: map()) :: {filename :: String.t(), iodata :: iodata(), mime :: String.t()}
Renders the export content.
format_key must be one of the atoms from formats/0.
ctx is a map with keys: :items, :index, :catalogues.
Returns {filename, iodata, mime_type}.