Check and preview a custom template locally
Before you push a custom template, check it and look at it on your
own machine. Run two commands at the root of your repository, where edgekit.yaml is. Both read your templates from
its templates folder, edgekit/templates/ unless edgekit.yaml’s
paths.templates names another, which holds
templates/<name>/index.tsx:
edgekit templates validateruns every check a push runs, and pushes nothing.edgekit templates devserves every fixture as an email and as a web page, and reloads the page each time you save.
Both build each template the way edgekit templates push does, with your vite.config.ts when there is one.
Check a template
Section titled “Check a template”edgekit templates validateedgekit templates validate digest weeklyWith no name, the command checks every template under templates/. It needs no sign-in and sends nothing to
EdgeKit. EdgeKit’s checks run on your machine, from the CLI’s own copy of them:
- The build: no Node built-in, no imported image or stylesheet, one ES module with a default export, at most 5 MB.
- The name rule, and a manifest whose name is the directory’s.
- Every check a push runs: every fixture in every locale the template lists, finished as an email and as a web page, with the same sentence for each failure and the same size warnings.
The command prints one line per template, in the same words as a push:
Valid digest: it passes every check a push runs. Refused weekly: The template failed push validation on 1 check. - Fixture "emptySlots" (en): The template threw: "Cannot read properties of undefined (reading 'headline')".It checks every template, even after one is refused, and exits with status 1 when any template is refused.
--json prints one JSON object with every result instead. A build that fails counts as a refusal of that template.
On your machine, the template runs in Node with what EdgeKit’s sandbox takes away taken away: no network access, no
environment variables, none of Node’s own globals, such as process, Buffer and require, and no code built
from a string (eval, new Function) or WebAssembly compiled at run time. Each render may
take 10 seconds. EdgeKit’s sandbox also limits each render to 2,000 ms of processor time, which only a push or
--remote checks. If the two ever disagree, the sandbox is right: --remote runs the template there.
Check in EdgeKit without pushing
Section titled “Check in EdgeKit without pushing”edgekit templates validate --remote--remote sends each build to EdgeKit, which checks it as a push does, in the sandbox that renders your sends. It
stores nothing: no template bundle, no version, no change to the draft, and no entry in your audit log. It needs the
template:write permission and a credential, picked as for
a push. When EdgeKit cannot run the check, the
command prints EdgeKit could not run the template to check it: validate again.
Preview a template
Section titled “Preview a template”edgekit templates devedgekit templates dev digest --port 5000The command builds and checks each template, then serves a page at http://127.0.0.1:6400/ until you stop it with
Ctrl-C. --port 0 picks any free port. The page lists each template with the result validate prints, then each
fixture in each locale the template lists, with two links:
- email: the email as Braze receives it. Braze Liquid, such as the first-name placeholder and the unsubscribe link, shows as text where it is visible, and is marked in the HTML source below the email. The unsubscribe link is a placeholder that signs nothing.
- web: the page your archive shows, with no Liquid and no unsubscribe link.
Each page shows the fixture’s refusals, and the email’s size with click tracking, with the same warnings as a push: from 90 KB, over 102 KB and over 400 KB.
Saving a template, a file it imports, a fixture or vite.config.ts rebuilds every template and reloads every open
page. The terminal prints each template’s result again.
Your own fixtures
Section titled “Your own fixtures”Put editions of your own in fixtures/ in the templates folder, one JSON file each. A file has the shape of
an @edgekitcloud/email/fixtures fixture: contract 2’s input
without props.
{ "edition": { "slots": [ { "kind": "rich_text", "position": 0, "title": "Lead", "blockKey": "rich-text", "blockProps": {}, "content": [] } ], "sendAt": null, "timezone": null }, "brand": null}edgekit templates dev lists each one as fixtures/<file>, beside EdgeKit’s fixtures. It renders them in each
locale the template lists, with the same props as EdgeKit’s fixtures: the template’s fixtureProps, or {}. A file
that is not JSON, has no edition.slots list, or has a slot without a whole-number position is named at the top of
the page, with what is wrong, and is not rendered.
Your fixtures are for previews only. edgekit templates validate and edgekit templates push never read them: a push
is checked against EdgeKit’s fixtures alone. dev runs the same checks on your fixtures, and lists what fails under
the template’s result, apart from it: a refusal there does not stop a push.
Preview a real edition
Section titled “Preview a real edition”edgekit templates dev --edition <edition id>--edition also renders one of your editions, as its preview in the console renders it: feeds resolved at its send
time, empty slots left out, and the props of the publication’s main variant. The page lists it as
edition <id> (variant <name>), as an email and a web page. When the main variant uses another template, the page
names that template: the props are written for it, so your template may refuse them.
The CLI fetches the edition once, when the command starts. Restart the command to see later changes to the
edition. It needs the template:write permission, which the Owner, Admin and Developer roles have, and a
credential, picked as for a push.
The edition can hold content that is scheduled or under embargo. The CLI keeps it in memory, never prints it, and
serves the page on 127.0.0.1 only: the server refuses a request addressed to any other host name.
Start from emails you received
Section titled “Start from emails you received”edgekit templates extract ~/Downloads/newslettersedgekit templates extract weekly.eml --out ./extractTo recreate a newsletter you already send, start from copies of it. extract reads one .eml file, one mbox, or a
folder of them. It writes each message’s HTML part as NN.html and an outline of it as NN.txt, plus one
manifest.json, to a new temporary folder, or to --out. It sends nothing anywhere and reads nothing the emails
link to.
The outline is the email in reading order, one line per run of text, image, or bordered or filled box, with the style
each line inherits. A link keeps its host and path and drops its query. Every address the email was sent to reads
<recipient>. The command prints one line per message, oldest first, with the section labels it shares with the
other messages. A message with no HTML part is listed as refused. --out must be a new folder or an earlier
extract’s.
The outline is what an agent reads to write a template to the emails’ design. Your fixtures, not the extract, belong in your repository.