Letterpress.Profile (Letterpress v0.1.0)

Copy Markdown View Source

Resolves versioned template profiles from the generated contract.

A profile fixes the source language, output channels, allowed elements and attributes, formatting rules, and compiler behavior. Existing identifiers never change meaning; incompatible behavior requires a new identifier.

Unsupported or malformed identifiers fail before compiler work begins.

Example

iex> Letterpress.Profile.all()
["email/mjml-liquid@1", "html/liquid@1", "text/liquid@1"]

Summary

Functions

Returns the supported profile identifiers in lexical order.

Fetches the generated metadata for a profile.

Validates a public profile identifier.

Functions

all()

@spec all() :: [String.t()]

Returns the supported profile identifiers in lexical order.

fetch(profile)

@spec fetch(String.t()) :: {:ok, map()} | :error

Fetches the generated metadata for a profile.

Returns :error when the identifier is not present in the current contract.

Example

iex> {:ok, metadata} = Letterpress.Profile.fetch("email/mjml-liquid@1")
iex> metadata["kind"]
"email"

validate(profile)

@spec validate(term()) :: :ok | {:error, [Letterpress.Diagnostic.t()]}

Validates a public profile identifier.

Examples

iex> Letterpress.Profile.validate("text/liquid@1")
:ok

iex> {:error, [diagnostic]} = Letterpress.Profile.validate("unknown")
iex> diagnostic.code
"LP_PROFILE_UNKNOWN"