Templates Editor 0.1.0: Edit email template files from the admin
Templates editor 0.1.0 is the first release of a PhoenixKit module that edits your app’s email template files from the admin: the subject, HTML and text of each email, its layout and its translations, with a preview and a test send to yourself.
Email templates in the settings
The templates stay files in your app, in the directory phoenix_kit_templates renders emails from, deployed with your code. The module adds an Email templates section to Settings › Emails Transactional. It shows an introduction, your project’s own README.<language>.md from the templates folder if there is one, and the files changed on the server but not committed to git (Show what is not committed to git).
Editing needs editable: true in the config and the Edit email templates permission, both checked on the server at every change. Without them the templates are shown read only. A part changed on disk since it was opened is not saved over; Reload reads the files again. Every change goes into PhoenixKit’s activity log.
Layouts and variables
Layouts lists each layout group with its header, footer and layout parts and the emails that use them. New layout copies another one, a layout no email uses can be deleted, and each email picks its own Layout. The Variables panel lists a part’s variables with samples and puts one at the cursor. A save with a variable of the wrong kind asks for Save anyway, and an unknown one gets a warning. A subject must be one line.
Emails that core and modules send
The emails PhoenixKit core and other modules send are shown read only until given a file of your own. The overridable setting decides which ones may be: none by default, a list by name, or :all. Even :all leaves out core’s sign-in emails, which carry a warning wherever they are shown. For an email core sends, the editor shows where each part really comes from, and a red notice when a database template wins over the files.
Preview and test send
Preview shows the email in its layout. Send to me sends it to the person asking only, at most once in 30 seconds, and logs it. The interface comes in English, Estonian and Russian.
Upgrading
Add {:phoenix_kit_templates_editor, "~> 0.1"}; it needs PhoenixKit 2.57 or later (below 3.0) and phoenix_kit_templates 0.2.3 or later. There is no migration. Switch the module on at Admin › Modules, where it is Templates editor; it is off by default. Add PhoenixKitTemplatesEditor.Web.ScopeHook to extra_live_session_on_mount in the :phoenix_kit config, or the section stays read only. Where files are edited, make the templates folder a setgid directory of your team’s group and give the server the umask 0002, so the files it writes stay editable by the people who commit them.
Full release notes: Templates Editor 0.1.0
0.1.0 · 10 October 2026
Added
PhoenixKitTemplatesEditoras aPhoenixKit.Module: keytemplates_editor, off by default (templates_editor_enabled), a card on Admin › Modules, the permissiontemplates_editorwith the sub-permissiontemplates_editor.write.- The “Email templates” section on Settings › Emails Transactional, with a
button beside “Preview emails”: an introduction, hints, the project’s
README.<language>.mdfrom the templates root, the files not committed to git (on a button and after every change), and the editor wired to the config. Writing needseditable: trueandtemplates_editor.write, checked throughPhoenixKitTemplatesEditor.Web.ScopeHook(a live-session hook the host adds). PhoenixKitTemplatesEditor.Files: cache reload under every path naming the root; no mode or owner changed after a write (they come from a setgid root and the server’s umask, see the README);git statuswithout hooks, filter drivers orGIT_*variables, with a deadline and its stderr dropped;safe_read/2refusing links, paths out of the root and oversized files.PhoenixKitTemplatesEditor.Watcher: where files are edited or watched, a change on disk drops the cache within 2 s.PhoenixKitTemplatesEditor.ConvertersandPhoenixKitTemplatesEditor.HtmlText(extracted from a host application): Markdown/HTML to text and Markdown to HTML with placeholders kept, size limit, deadline, linear-time patterns.PhoenixKitTemplatesEditor.Preview: the default preview in the email’s layout group;PhoenixKitTemplatesEditor.Catalog: the host’s emails for core’s “Preview emails” withcatalog: true.tab_path/1,accessible?/1andauthorize/2for hosts and for per-event checks.PhoenixKitTemplatesEditor.Config: reads and checksconfig :phoenix_kit_templates_editor, returning every problem instead of raising.PhoenixKitTemplatesEditor.Web.Editor, the editor component moved fromphoenix_kit_templates0.2.4 (PhoenixKit.Templates.Editor), now in the page’s language. New: every change checkseditableand the host’sauthorizeon the server; an email incomplete in the base language is flagged (base_locale,complete?);email_fallback: falsehides an email’s unused Fallback tab, showing left-over locale-less files read-only with a delete button. Every file is read throughFiles.safe_read/2; the preview frame hasreferrerpolicy="no-referrer"and acspallowing images only inline and from the host’s origins.- Layouts (
_header-<g>,_footer-<g>,_layout-<g>) in the editor: the layouts oflayout_groupswith their own and inherited parts and the emails using each, a new layout as a copy of another, deleting one no email uses, and an email’s layout choice (layout.txt). The default preview shows a layout’s part around the first email using it. PhoenixKitTemplatesEditor.Names: the shared layout parts only withshared_layout_editable: true, the emails core and other modules send never, layout groups by exact namespace (a prefix_header-shopno longer allows_header-shopx).PhoenixKitTemplatesEditor.Layouts: a root’s layouts.- A copy of a template lists the host’s own files in it to leave out.
- Module emails: the emails core and other modules send, read only until
given a file — from the built-in text by language, or from the Emails
module’s active database template by its export — where
overridableallows it: none by default, a list by name, oroverridable: :allas an explicit choice of every one but core’s sign-in emails (which carry a warning wherever shown). A module’s own layout group the same way.PhoenixKitTemplatesEditor.Overriding. - What is sent: for an email core sends, the source of each part through
core’s resolution, with a red notice when a database template wins over the
file (
PhoenixKitTemplatesEditor.Sources); an email the host sends says so (sent_by). - The variables panel (
PhoenixKitTemplatesEditor.Variables): a part’s variables by its kind of template with samples and the host’s descriptions, inserted at the cursor by a JS hook (js_sources/0) or at the end of the body without it; saves checked — a variable of the other kind only after “Save anyway”, an unknown one with a warning,{{{x}}}only forraw_variablesand a layout’scontent/header/footer, a subject one line of at most 998 bytes. - Send to me (
PhoenixKitTemplatesEditor.TestSend,Throttle): to the user asking only, once in 30 s, logged; the host’s own emails by itstest_send, if any, the rest byPhoenixKit.Mailer. - A part changed on disk since it was opened is not saved over; Reload reads the files again.
- Every change in PhoenixKit’s activity log (
PhoenixKitTemplatesEditor.Journal). - Translations: English, Estonian, Russian.
Templates Editor 0.1.0. Install or update: {:phoenix_kit_templates_editor, "~> 0.1"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.