Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / getTheme

Function: getTheme()

getTheme(doc): EmailTheme

Defined in: rcml/src/email/get-theme.ts:56

Extract the EmailTheme encoded in an rcml document's head.

Walks <rc-head> / <rc-attributes> and reads back every theme- controlled node (brand-style id, body/section/button backgrounds, brand-color / logo / font-style classes, social block, <rc-font> children). Missing fields fall back to the defaults from theme-defaults.ts, so the return value is always a full EmailTheme — safe to pass to applyTheme or any other consumer.

A bare doc with no theme returns the same shape as createEmailTheme(). Unknown or malformed rcml nodes are ignored silently; nodes that look right but are missing required attributes are skipped. Input is not mutated.

Parameters

doc

RcmlDocument

The rcml document to inspect.

Returns

EmailTheme

A fully-populated EmailTheme. brandStyleId is omitted when the doc lacks <rc-brand-style>; every other field is always present, using defaults for any slot the doc doesn't cover.