Mailglass.Installer.Templates (Mailglass v0.3.2)

Copy Markdown View Source

Installer template helpers for owned files and managed shared-file patches.

Summary

Functions

Returns the starter layout template content.

Returns the default mailable stub source.

Marker line for the end of the managed endpoint webhook-parser block.

Marker line for the start of the managed endpoint webhook-parser block.

Returns the verbatim Plug.Parsers body_reader config block inserted into endpoint.ex.

Returns the generated mail context module source.

Wraps a managed block body with explicit start/end markers.

Returns the generated Oban worker stub source.

Anchor substring used to insert router snippets.

Returns the snippet inserted into router.ex for the Mailglass admin surface.

Marker line for the end of the managed runtime config block.

Marker line for the start of the managed runtime config block.

Returns the managed block body inserted into runtime.exs.

Returns the snippet inserted into router.ex for the Mailglass webhook surface.

Functions

default_layout()

@spec default_layout() :: String.t()

Returns the starter layout template content.

default_mailable(opts \\ [])

@spec default_mailable(keyword()) :: String.t()

Returns the default mailable stub source.

endpoint_webhook_block_end()

@spec endpoint_webhook_block_end() :: String.t()

Marker line for the end of the managed endpoint webhook-parser block.

endpoint_webhook_block_start()

@spec endpoint_webhook_block_start() :: String.t()

Marker line for the start of the managed endpoint webhook-parser block.

endpoint_webhook_parser_body()

@spec endpoint_webhook_parser_body() :: String.t()

Returns the verbatim Plug.Parsers body_reader config block inserted into endpoint.ex.

mail_context_module(opts \\ [])

@spec mail_context_module(keyword()) :: String.t()

Returns the generated mail context module source.

managed_block(start_marker, end_marker, body)

@spec managed_block(String.t(), String.t(), String.t()) :: String.t()

Wraps a managed block body with explicit start/end markers.

oban_worker_stub(opts \\ [])

@spec oban_worker_stub(keyword()) :: String.t()

Returns the generated Oban worker stub source.

router_anchor()

@spec router_anchor() :: String.t()

Anchor substring used to insert router snippets.

Phoenix 1.5+ routers conventionally have use MyAppWeb, :router as the first non-defmodule line. The macro expands to use Phoenix.Router at compile time, but the source file does NOT contain that literal — so an earlier version of this anchor ("use Phoenix.Router") silently failed to match real adopters' routers and fell through to conflict-sidecar behavior. Match , :router instead, which appears in use FooWeb, :router and is rare elsewhere in router source.

Adopters still on Phoenix < 1.5 with the literal use Phoenix.Router call must run mix mailglass.install --force (the anchor-not-found + force fallback) and manually move the appended snippets inside the module block. v0.1+ targets Phoenix 1.7+ per STACK.md, so this case is not the default-supported path.

router_mount_snippet(opts \\ [])

@spec router_mount_snippet(keyword()) :: String.t()

Returns the snippet inserted into router.ex for the Mailglass admin surface.

runtime_block_end()

@spec runtime_block_end() :: String.t()

Marker line for the end of the managed runtime config block.

runtime_block_start()

@spec runtime_block_start() :: String.t()

Marker line for the start of the managed runtime config block.

runtime_config_body()

@spec runtime_config_body() :: String.t()

Returns the managed block body inserted into runtime.exs.

Sets Swoosh's :api_client to Swoosh.ApiClient.Finch because Finch ships with mix phx.new (it's the default HTTP client for the host Phoenix app). Swoosh's own default at v1.25 is Swoosh.ApiClient.Hackney which would require adopters to add {:hackney, "~> 1.18"} and start a hackney supervisor manually. With Finch, no extra deps or boot wiring is needed — adopters can mix mailglass.install and immediately mix phx.server without surprise.

webhook_mount_snippet(opts \\ [])

@spec webhook_mount_snippet(keyword()) :: String.t()

Returns the snippet inserted into router.ex for the Mailglass webhook surface.