Emails 0.5.5: Safer template variables and a template editor that keeps translations
Emails 0.5.5 makes variables in the PhoenixKit email templates safe by default in HTML, shows when a database template is hiding a file or a built-in default, and fixes several ways the template editor lost text.
Variables are escaped in HTML
In a template’s HTML body, {{name}} now inserts the value as text, with HTML special characters escaped. To insert ready-made HTML, write {{{name}}} with three braces. A new migration, V3, rewrites {{line_items_html}} and {{line_items_table_html}}, billing’s ready-made order tables, to the three-brace form in every stored template. Until it runs, those two names still go in as raw HTML, so order emails keep showing a table.
Which template is in charge
The Templates list and the editor now mark an active template that hides another one: File override shadowed when the host app has a file for the same name, Default shadowed when PhoenixKit or a module ships a default for it. On a PhoenixKit without the needed functions, no badge is shown.
Editor fixes
- The preview follows what you type, fills in sample values and is translated. Variable hints are placeholders and are no longer saved into the template.
- Saving no longer turns fallback text into a translation of its own, and keeps translations for languages that have no enabled tab. An empty language field is dropped instead of saved, while clearing a text still removes that translation.
- New templates start with an HTML and a text body in the selected language; the starter content used to be lost.
- After a save, the form, preview, variables, title and version show the saved template.
- The use counter no longer loses counts when several emails go out at once, and a failed or log-only test send no longer counts as a use.
Upgrading
Run mix phoenix_kit.update to apply migration V3. If any of your templates put HTML into a variable other than billing’s two tables, change it to {{{name}}}, or the HTML will show as text.
Full release notes: Emails 0.5.5
0.5.5 · 13 October 2026
Added
- Migration V3 (PR #53): in every stored
html_body,{{line_items_html}}and{{line_items_table_html}}become the raw form{{{...}}}. Runmix phoenix_kit.updateafter upgrading; until then the renderer still inserts those two names raw, so mail keeps sending a table.down/1below 3 runs the inverse. - The templates list and the editor say when an active row shadows a host file
override or a default shipped by core or a module (
TemplateSources,SourceBadges; PR #57). On a core without the APIs it reads, nothing is shown. - The editor preview follows what is typed, uses sample values and is translated (PR #55); variable hints are placeholders and are never saved into the row (PR #54).
Changed
{{name}}is HTML-escaped inhtml_body;{{{name}}}inserts raw. One tokenizer now reads placeholders for extraction, substitution, the unbound warning and the export (PR #53). A variable value that is a map, list or tuple raisesArgumentErrornaming the variable.Templates.create_template/2,update_template/3andclone_template/4take the author ascreated_by_user_uuid:/updated_by_user_uuid:options; the audit columns are no longer cast from attrs. A submittedmetadatais merged into the stored one (PR #54).- A locale left empty is dropped instead of saved as a translation (PR #54).
Provider.track_usage/1returns:ok, as the core callback declares.
Fixed
- The editor no longer writes fallback text into a locale as a translation of
its own, and no longer overwrites
cloned_fromin metadata (PR #54). usage_countlost concurrent updates; it is nowusage_count + 1in the database. A failed or log-only test send no longer counts as a use (PR #56).- The
Every translation must be texteditor message was missing its Estonian and Russian translations. - Saving or validating in the editor preserves stored translations for languages without an enabled tab, including base-language keys on hosts using regional tabs. Submitting empty text still removes that translation.
- New templates now start with HTML and text bodies in the selected language; the form previously passed strings to map fields and lost the starter content.
- After a save, the editor refreshes its form, preview, variables, title and version from the saved row.
- Optional description translations now reject non-text values through the context API too, while empty descriptions remain valid.
- Catalog entries without content defaults no longer get a “Default shadowed” badge. Default callbacks remain unevaluated when loading source badges.
Emails 0.5.5. Install or update: {:phoenix_kit_emails, "~> 0.5"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.