Expand description
Renders email bodies, stored as the Gutenberg blocks the CMS email editor saves, into the HTML and plain-text parts of a message.
StructsΒ§
- Email
Gutenberg Block - One block of an email body. Rich-text attributes (see
EmailBlockName::is_rich_text_attribute) are HTML, sanitized when rendered; every other attribute is plain. - Email
Layout Fields - What a shellβs placeholders are filled with.
- Email
Render Input - What a message is rendered from: a body and subject with
{{KEY}}placeholders, and the layout it is wrapped in. - Email
Theme - Colours the renderer writes inline, as
#RRGGBB. Outlook desktop and clients that strip<style>read only these, so a shellβs CSS alone cannot rebrand them. - Rendered
Email - A message ready to hand to the mail relay.
- Table
Cell π
EnumsΒ§
- Email
Block Name - Block types an email body may contain; must match
allowedEmailCoreBlocksandblockTypeMapForEmailsin the CMS. Any other type fails deserialization, so a body is never sent with a block silently left out.
ConstantsΒ§
- CALLOUT_
BACKGROUND_ πCOLOR - CALLOUT_
BORDER_ πCOLOR - DEFAULT_
EMAIL_ LAYOUT - The shell used when no
email_layoutsrow applies. - DEFAULT_
EMAIL_ THEME - The theme of
DEFAULT_EMAIL_LAYOUT. Must match the column defaults ofemail_layouts. - DEFAULT_
SPACER_ πHEIGHT_ PX - EMAIL_
ASSET_ πBASE_ URL - Where the images the renderer links to are served from:
services/main-frontend/public/static/email. Sent emails keep linking to these files, so they must never be renamed or removed. - IMAGE_
SCHEMES π - LINK_
SCHEMES π - MAX_
IMAGE_ πWIDTH_ PX - The width of the content column of the shells: 640px minus 40px padding on both sides.
- MAX_
SPACER_ πHEIGHT_ PX - ONE_
TIME_ πCODE_ BACKGROUND_ COLOR - ONE_
TIME_ πCODE_ BORDER_ COLOR - ONE_
TIME_ πCODE_ FONT_ FAMILY - ONE_
TIME_ πCODE_ TEXT_ COLOR - QUOTE_
BORDER_ πCOLOR - QUOTE_
TEXT_ πCOLOR - RICH_
TEXT_ πTAGS - The inline formatting Gutenbergβs rich text produces that email clients render. Not
mark: old highlights lose their colour styles to the sanitizer, and a baremarkis painted yellow. - UNCHANGED_
ALT_ πTEXT - What the CMS stores as an imageβs alt text until the author writes one. Must match
ALT_TEXT_NOT_CHANGED_PLACEHOLDERinservices/cms/src/services/altTextPlaceholder.ts.
StaticsΒ§
- ALL_
TAG_ πREGEX - CSS_
INLINER π - HREFLESS_
LINK_ πREGEX - IMG_
TAG_ πREGEX - LAYOUT_
PLACEHOLDER_ πREGEX - LINK_
REGEX π - PLACEHOLDER_
REGEX π - PREPENDED_
PROTOCOL_ πBEFORE_ PLACEHOLDER_ REGEX - PREPENDED_
PROTOCOL_ πIN_ HREF_ REGEX - QUOTE_
VALUE_ πSANITIZER - For the
valueof quotes saved before quotes held inner blocks, which is a run of<p>s. - RICH_
TEXT_ πSANITIZER - SRC_
ATTRIBUTE_ πREGEX - WHITESPACE_
REGEX π
FunctionsΒ§
- block_
to_ πhtml - block_
to_ πplaintext - callout_
icon_ πfile - The hosted PNG for a calloutβs
iconattribute;Nonefor βnoneβ and unknown values. - fill_
placeholders - Replaces
{{KEY}}in every attribute, nested blocks included. Values are HTML-escaped in rich text and inserted as is elsewhere; a protocol Gutenberg prepended to a link whose whole target is a placeholder is dropped. Returns the keys found thatreplacementshas no value for; those are left in place. - fill_
placeholders_ πin_ blocks - fill_
placeholders_ πin_ text - fill_
placeholders_ πin_ value - html_
to_ πpreformatted_ text - Like
html_to_text, but keeps the first lineβs indentation. - html_
to_ πtext - Rich text to plain text. A link keeps its target, since the plain-text part has no other way to show it.
- inline_
css π - Copies the
<style>rules onto the elements they match, for clients that drop<style>. - layout_
warnings - Problems that make a shell render badly: a missing
{{SUBJECT}},{{PREHEADER}}or{{LANGUAGE}}, or an image not loaded over https, which clients block or warn about. Empty when none is found; a heuristic, not validation. - list_
to_ πplaintext - preheader
- The inbox preview: the first paragraph as one line of text, or empty when there is none.
- process_
content_ to_ html - Renders a body into the HTML a shellβs
{{CONTENT}}is replaced with. - process_
content_ to_ plaintext - Renders a body into the plain-text part of a message. Links keep their targets in the text.
- render_
email - Renders a whole message. The one path both sending and previewing go through, so a preview shows what is sent.
- replace_
placeholders π - rich_
text_ πsanitizer - sanitize_
rich_ πtext - url_
with_ πscheme urltrimmed, if it is absolute with one ofschemes.- wrap_
in_ layout - Wraps a rendered body in an email shell:
{{CONTENT}}gets the body as is,{{SUBJECT}},{{PREHEADER}}and{{LANGUAGE}}their escaped values. One pass, so placeholders inside the body are never expanded.